我想将当前日期与我的数据库中类型日期的其他字段进行比较。此外,我还需要将当前时间(我的时区是以色列)与数据库中的其他字段进行比较。 这是我得到的输出:
connection success
UTC
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':36:04pm > event.start_time' at line 1
这是我的PHP代码:
<?php
/**
* Created by PhpStorm.
* User: matant
* Date: 11/17/2015
* Time: 1:46 PM
*/
define ('mysql_host','pdb3.biz.nf');
define ('mysql_user','1934398_gpsport');
define ('mysql_password','gpsportBraude15');
define ('myDB','1934398_gpsport');
define ("GOOGLE_API_KEY","AIzaSyBSGW3kNZ_GNsBsTdJBKsyAbcTfaqv3uvo");
$dblink= mysqli_connect(mysql_host, mysql_user, mysql_password,myDB);
if (!$dblink)
{
$message = sprintf(
"Could not connect to local database: %s",
mysql_error()
);
trigger_error($message);
echo $message;
return;
}
else{
echo "connection success"."<br/>";
}
$c_date = date("Y-m-d");
$c_time = date("h:i:sa");
date_default_timezone_set('Europe/Jerusalem');
$my_time = date_default_timezone_get();
echo $my_time."<br/>";
$query = "UPDATE event SET event_status = '0' WHERE event.event_date < '$c_date' OR $c_time > event.start_time";
$res = mysqli_query($dblink,$query) or die (mysqli_error($dblink));
if(!$res){
echo "failed to update event!"."<br/>";
echo $my_time."<br/>";
}
else{
echo "event updated successfully";
}
$dblink ->close();
?>