这简直是疯了。似乎没有什么问题:
$q_messages = $db->query( "SELECT `messages`.`MessageID`, `messages`.`MsgDate`, `messages`.`MsgStatus`, " .
"`messages`.`Subject`, `messages`.`Message`, CONCAT(users.LastName, ', ', users.FirstName) SenderName " .
"FROM `messages` " .
"INNER JOIN `users` ON `messages`.`Sender` = `users`.`UserID` " .
"WHERE (`messages`.`Recipient`=$userid)" );
该查询导致引发以下错误:
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 '\', \', users.FirstName) SenderName FROM `messages` INNER JOIN `users` ON `messa' at line
我还尝试在 concat 函数中将 ', ' 替换为 \", \" ,但这也没有解决问题。顺便说一句,如果我删除 concat 函数的第二个参数,它可以工作
PS。我在 phpmyadmin 中运行了查询,它成功了!
这是回显的sql。对不起,我一开始没有意识到你的意思:D
SELECT `messages`.`MessageID`, `messages`.`MsgDate`, `messages`.`MsgStatus`, `messages`.`Subject`, `messages`.`Message`, CONCAT(users.LastName, ', ', users.FirstName) SenderName FROM `messages` INNER JOIN `users` ON `messages`.`Sender` = `users`.`UserID` WHERE (`messages`.`Recipient`=30)