[英]why am I getting Error: Query was empty?
I am getting this error when I try to use the following code! 尝试使用以下代码时出现此错误! I don't understand the reason. 我不明白原因。 I assume its something to do with the UPDATE but i dont get what it is! 我认为它与更新有关,但我不知道它是什么!
<?php
$con = mysql_connect("localhost","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
mysql_query("UPDATE pages SET pagebody = 'firstname'");
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
You don't select database here mysql_select_db("[db name]", $con);
您无需在此处选择数据库mysql_select_db("[db name]", $con);
. 。 And another thing, are you planning to update all entries in the pages table? 另外,您是否打算更新pages表中的所有条目? Because you don't have a WHERE
clause. 因为您没有WHERE
子句。 The comments here have their points though. 虽然这里的评论有他们的观点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.