Im Versuch, eine einfache UPDATE Abfrage auszuführen:UPDATE Syntax in MySQL 5.7
UPDATE students SET enterTime = '".$enterTime."' WHERE s_id = '".$s_id."'; UPDATE timeLimit SET listed = listed + 1 WHERE enterTime = '".$enterTime."' AND building = '".$building."';"
Es funktioniert gut in MySQL-Version 5.1, mein Server MySQL-Version 5.7 aktualisiert wurde, und ich erhalte die folgenden Fehler:
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");
}
}
Vielen Dank für Ihre Hilfe!
Diese Abfrage phpMyAdmin oder mysql cli läuft – MuthaFury
Aus dem Fehler, scheint es, wie Sie die Abfrage sind Looping, versuchen Sie überprüfen Ihre Looping – MuthaFury
Wie beurteilen Sie die Abfrage (PHP-Code) laufen? –