假设我在php/mysql查询中有一个错误:
$query = "SELECT * ROM users WHERE _id = :user_id";
在这里,FROM缺少一个"F“。当我在localhost中启动这个php文件时,我的浏览器没有反应,它应该显示如下内容:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
但事实并非如此,只有空白页..。如何启用此选项?
编辑:我正在使用PDO。
发布于 2012-06-18 13:21:46
如果你使用mysql_*
函数,你必须这样做:mysql_query($sql) or die(mysql_error());
$stmt->execute() or die(print_r($stmt->errorInfo)); //$stmt is instance of PDOStatemen
,你使用mysqli_*
:PDO
如果你还在使用mysql_*
,我强烈建议你停止使用(我的意思是sql注入)。
发布于 2012-06-18 13:13:20
if(!mysql_query($query)){ echo mysql_error();}
然后在浏览器上检查错误。
https://stackoverflow.com/questions/11083571
复制