Im trying to run a simple UPDATE query:
UPDATE students SET enterTime = '".$enterTime."' WHERE s_id = '".$s_id."'; UPDATE timeLimit SET listed = listed + 1 WHERE enterTime = '".$enterTime."' AND building = '".$building."';"
It works fine in MySql version 5.1 , my server has been upgraded to MySql version 5.7 and I get the following error:
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 'UPDATE students SET enterTime = '09:00' WHERE ' at line 1 BEGIN; UPDATE students SET enterTime = '09:00' WHERE s_id = '312433931' ; UPDATE timeLimit SET listed = listed + 1 WHERE enterTime = '09:00' AND building = '2'; UPDATE timeLimit SET listed = listed - 1 WHERE enterTime = '08:00' AND building = '2'; COMMIT;
PHP code:
function update_time_for_student($student,$enterTime,$oldTime){
$s_id = $student['s_id'];
$building = $student['building'];
$query = "BEGIN; UPDATE students
SET enterTime = '".$enterTime."'
WHERE s_id = '".$s_id."' ;
UPDATE timeLimit
SET listed = listed + 1
WHERE enterTime = '".$enterTime."' AND building = '".$building."';
UPDATE timeLimit
SET listed = listed - 1
WHERE enterTime = '".$oldTime."' AND building = '".$building."'; COMMIT;";
if (mysql_query($query)){
$fullName = $student['fname']." ".$student['lname'];
send_email($student['email'],$enterTime,$fullName,$s_id);
header("Location:/index.php?d=1");
} else {
echo mysql_error();
echo "<br/>";
echo $query;
//header("Location:/index.php?d=3");
}
}
Thank you very much for your help !