PHP PDO。查询正确时,错误号“00000” [英] PHP PDO. error number '00000' when query is correct
本文介绍了PHP PDO。查询正确时,错误号“00000”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下面的代码:
$sql3 = "update news set date='$time' where id='2'";
$sql3 = $connect->exec($sql3);
if(!$sql3)
{
print_r($connect->errorInfo());
$error = $connect->errorInfo();
die ("Error: (".$error[0].':'.$error[1].') '.$error[2]);
}
当我运行脚本时,有时会得到错误号'00000'。我的意思是介绍 IF
。它都是随机的。输出(有时):
When I run the script, sometimes I get error number '00000'. I mean it goes intro the IF
. and it is all random. output (sometimes):
Array ( [0] => 00000 [1] => [2] => )
我该如何解决这个问题?
PS:
What should I do to fix this problem ?
PS: The script executes correctly every time.
推荐答案
PDO错误代码 00000
一切工作正常。你碰到错误检查代码的原因是 $ sql3
返回0(没有行受到影响),PHP评估为false。尝试显式检查 return false;
The PDO error code 00000
means that everything works fine. The reason you're hitting the error-checking code is that $sql3
is returning 0 (no rows were effected) and PHP evaluates that to false. Try explicitly checking for a return false;
if($sql3 === false)
这篇关于PHP PDO。查询正确时,错误号“00000”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文