Mysql Error: Query was empty

2019-09-01 16:56发布

问题:

Can anyone tell me why I am getting this error when running my syntax

Error:

Query was empty

Code:

$con= mysql_connect("xxx","cl49-xxx","xxx");
if (!$con) 
{
  die('Could not connect: ' . mysql_error());
}

mysql_select_db("cl49-xxx", $con);

foreach($_POST as $key=>$value) {
  echo "<b>$key:</b> $value<br />";
} 
echo"<br /><br />";
$result = mysql_query("UPDATE pages SET pagename='$pagename' WHERE pageid ='$pageid'") or die(mysql_error());

if (!mysql_query($sql,$con)) { 
  die('Error: ' . mysql_error());
}
mysql_close($con); 
echo' <h2><font color="green">Page Updated Succesfuly</font> </h2>';

Can anyone help?

回答1:

In this query $sql is used but is is not defined anywhere in you code snippet.

if (!mysql_query($sql,$con)) { 
  die('Error: ' . mysql_error());
}

If you remove above code this message will not come again.