mysql - Deleting dates with PHP -


this question has answer here:

i trying code below delete dates between 2 selected dates. showing error provided , not deleting database not sure why? if take look, appreciative.

if(isset($_post['remove'])){  $servername = "localhost"; $username = "u779108225_admin"; $password = "password"; $dbname = "u779108225_main";  // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) {     die("connection failed: " . $conn->connect_error); }   $date_from = $_post['date_from'];  $date_from = strtotime($date_from); // convert date unix timestamp  // specify end date. date can english textual format $date_to = $_post['date_to']; $date_to = strtotime($date_to); // convert date unix timestamp  // loop start date end date , output dates inbetween ($i=$date_from; $i<=$date_to; $i+=86400) {     $date = date("y-m-d", $i);     echo $date;     $sql = "delete calendar date = $date)";      if ($conn->query($sql) === true) {         $complete = 'the dates have been removed database.';     } else {         $complete = 'an error has been detected, please try again later.';     } } echo $complete; $conn->close();  } 

i have tried changing variable in sql section include '' , "" nothing seems working?

put date quotes , remove ) query.

$sql = "delete calendar date = '" . $date . "'"; 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -