$result1 = mysql_query("Select * from tbl_lastLocation where driver_id='$user_id');
if(mysql_num_rows($result1)){
$result2 = mysql_query("UPDATE tbl_lastLocation SET Latitude='$Latitude',Longtitude='$Longitude',vehicle_id='$vehicle_id',data_create='$date_create',time_create='$time_create' WHERE driver_id='$user_id'"); //line 17
}
else{
$result2 = mysql_query("INSERT INTO tbl_lastLocation (driver_id,vehicle_id,Latitude,Longtitude,data_create,time_create) VALUES ('$user_id','$vehicle_id','$Latitude','$Longitude','$date_create','$time_create')");
}
$data["result"] = "1";
echo json_encode($data);
>
我收到错误:
PHP Parse error: syntax error, unexpected 'UPDATE' (T_STRING) in /home/barbodpl/public_html/its_api/lastlocation.php on line 17
错误意味着什么,我该如何解决?
答案 0 :(得分:1)
$result1 = mysql_query("Select * from tbl_lastLocation where driver_id='$user_id');
这缺少结束“因此它应该是:
$result1 = mysql_query("Select * from tbl_lastLocation where driver_id='$user_id'");
不推荐使用Mysql函数,请使用MySQLi和预处理语句,因为您的查询看起来很容易被注入。