gpt4 book ai didi

PHP UPDATE 'name' 中的未知列 'field list'

转载 作者:太空宇宙 更新时间:2023-11-03 11:28:40 25 4
gpt4 key购买 nike

在使用 PHP 更新数据库时,我似乎遇到了问题。我不断收到错误消息:

ERROR: Could not able to execute UPDATE settings SET value='0' WHERE id='2'. Unknown column 'value' in 'field list'

但列“值”确实存在,我已经尝试过人们在询问有关它的错误的相同问题时所说的内容,但到目前为止没有任何效果。这不起作用的原因是什么?

完整代码:

require 'config.php';

$link = mysqli_connect("LocalHost", "PSRPCADM", "999989Ki9?", "PSRPC");



// Check connection

if($link === false){

die("ERROR: Could not connect. " . mysqli_connect_error());

}



// Escape user inputs for security
if(isset($_POST['Monday']) &&
$_POST['Monday'] == 'Yes')
{
$monday = "1";
}
else
{
$monday = "0";
}



// attempt insert query execution


$sql = "UPDATE settings SET value='$monday' WHERE id='2'";




if(mysqli_query($link, $sql)){

echo "it worked";


} else{

echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);

}



// close connection

// close connection

mysqli_close($link);

最佳答案

value 是 mysql 中的关键字,您可以尝试在 value

之间使用引号字符
"UPDATE settings SET `value`='$monday' WHERE id='2'"

Keywords and Reserved Words

关于PHP UPDATE 'name' 中的未知列 'field list',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51866965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com