if(isset($_POST['select4']))
{$roomdes=$_POST['select4'];}
if(isset($_POST['select5']))
{$roomid=$_POST['select5'];}
$roomid=mysql_real_escape_string('$roomid');
$roomdes=mysql_real_escape_string('$roomdes');
if(isset($_POST['button2']))
{
$sql2="UPDATE master_table SET Room_booked=1 WHERE Room_type='$roomdes' AND Room_id='$roomid'";
$res3=mysql_query($sql2);
echo"done";
echo $sql2;
if(!$res3)
{echo"not being updated";}
else echo" \nupdatedddd\n";
}
此处更新已打印但我的表不会更新。我该怎么办?
答案 0 :(得分:2)
$roomid=mysql_real_escape_string('$roomid');
$roomdes=mysql_real_escape_string('$roomdes');
应该是:
$roomid=mysql_real_escape_string($roomid);
$roomdes=mysql_real_escape_string($roomdes);
当它们被包含在撇号中时(即'
),PHP假定字符串不是变量。
您还可以尝试以下操作来查看更新它是否有错误:
$res3 = mysql_query($sql2) or die(mysql_error());