我刚刚为 mysql 数据库编写了一个更新查询。问题既不是显示任何 mysql 错误,也不是更新行。my_sql_rows 总是输出假,这意味着我的表中没有任何更新代码如下
if(isset($_POST['update_subject']))
{
$id = $_POST['id'];
$menu_name = $_POST['menu_name'];
$visible = $_POST['visible'];
$position = $_POST['position'];
$content = $_POST['content'];
mysql_query("UPDATE subjects SET menu_name ='$menu_name', visible = $visible, position = $position,
content = '$content' WHERE id = $id ")
or die("updation of '$menu_name' in table subjects failed due to : " . mysql_error ());
if(mysql_affected_rows == 1 ) {
echo "Updation of '$menu_name' in table subjects is done successfully !!! ";
} else {
echo "something went wrong. updation process is halted.";
}
}
它总是返回我“出了点问题。更新过程已停止”我知道 mysql 命令已经过时但我仍然想学习。谢谢!