【问题标题】:error SQL (Update Set Where) on submit提交时出错 SQL (Update Set Where)
【发布时间】:2023-03-24 11:57:01
【问题描述】:

在用户以文本类型形式输入后,我目前在获取以下代码以更新 MySQLi 时遇到问题:

print "<input type='text' name='prof' >Prof<br />";    

$profselectorX=$_POST['prof'];
$profselector=$mysqli->real_escape_string($profselectorX);

$query="UPDATE homework1 SET 'prof'='".$profselector."' WHERE idnumber='".$editselector."'";
$resultz=$mysqli->query($query) or die($mysqli->error); 

提前谢谢你!

【问题讨论】:

  • 对列名使用反引号(col_name) 而不是单引号('col_name')

标签: php mysqli sql-update syntax-error


【解决方案1】:

像这样重写你的查询

$query="UPDATE `homework1` SET `prof`='$profselector' WHERE `idnumber`='$editselector'";

【讨论】:

    猜你喜欢
    • 2021-07-31
    • 1970-01-01
    • 2021-10-30
    • 2017-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-23
    相关资源
    最近更新 更多