2017-04-10 100 views
0

我有一個不會執行的mysqli查詢,我想顯示有關爲什麼發生這種情況的信息。我只是用這個例子鬼混但我想是這樣的:如何在php中顯示查詢錯誤

$myQuery= $mysqli->query("UPDATE table SET id = 1 WHERE id = 3"); 
if(!$myQuery) //If query couldnt be executed 
{ 
echo $mysqli->error; //Display information about why wasnt executed (eg. Error: couldnt find table) 
} 
+0

請檢查您的要求更新記錄 –

回答

1

嘗試使用

// Perform a query, check for error 
if (!mysqli_query($con,"UPDATE table SET id = 1 WHERE id = 3")) 
{ 
echo("Error description: " . mysqli_error($con)); 
} 

mysqli_close($con);