This question already has an answer here:
mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it?
(1个答案)
2年前关闭。
我有一个不会执行的mysqli查询,我想显示有关为什么发生的信息。我只是在愚弄这个例子,但我想像这样的事情:
(1个答案)
2年前关闭。
我有一个不会执行的mysqli查询,我想显示有关为什么发生的信息。我只是在愚弄这个例子,但我想像这样的事情:
$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)
}
最佳答案
尝试使用
// 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);
关于php - 如何在php中显示查询错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43315182/