我在運行此查詢時遇到問題。我不斷收到錯誤:PHP + MYSQL:更新時出現問題查詢
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);
並在地址欄中的URL:
http://localhost:8888/wmin/msg.php?user_id=1&msg_id=2
有誰看到我要去哪裏錯了嗎?謝謝!
我想我明白你在說什麼。我試過在它周圍放置反引號,沒有工作......然後我試圖改變表中的列名仍然沒有:/ – Stephen 2009-10-31 13:30:58