gpt4 book ai didi

PHP+MySQL : Problem with Update query

转载 作者:行者123 更新时间:2023-11-29 04:31:31 26 4
gpt4 key购买 nike

我在运行此查询时遇到问题。我不断收到错误消息:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read = 'readd' WHERE user_id = '1' LIMIT 1' at line 1

代码

 $conn = mysql_connect('localhost', 'admin', 'root') or die(mysql_error());
mysql_select_db('main') or die(mysql_error());

$read = "message read";

$set_statuss = "UPDATE inbox ".
"SET read = '".$read."' ".
"WHERE user_id = '".$_SESSION['user_id']."' ".
"LIMIT 1";

编辑:这是表格:

 CREATE TABLE `inbox` (
`inbox_id` int(5) NOT NULL auto_increment,
`posted_to` int(5) NOT NULL,
`posted_by` int(5) NOT NULL,
`subject` text NOT NULL,
`message` text NOT NULL,
`date_posted` datetime NOT NULL,
`read` text NOT NULL,
PRIMARY KEY (`inbox_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

编辑:更新了查询,但现在 PHP 只是显示为白色..

 $read = "read";

$set_statuss = "UPDATE inbox ".
"SET read = '".$read."' ".
"WHERE posted_to = '{$_SESSION['user_id']}' AND inbox_id = '".$_GET['msg_id'];."' ";

mysql_query($set_statuss) or die(mysql_error() . $set_statuss);

地址栏中的网址:

 http://localhost:8888/wmin/msg.php?user_id=1&msg_id=2

有人看到我哪里出错了吗?谢谢!

最佳答案

我认为它可能将 read 作为关键字,尝试将其删除,即在其周围使用 `` 反引号(很难用 SO 的 Markdown 语言表达;-)。

关于PHP+MySQL : Problem with Update query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1653370/

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