无法找到线路的错误

时间:2015-08-19 18:24:01

标签: php web

我发现什么是错的。在第一次会议之后发生了一些事情。

'SELECT m1.id, m1.title, m1.timestamp, count(m2.id) AS reps, users.id AS userid, users.username FROM pm AS m1, pm AS m2,users WHERE ((m1.user1="'.$_SESSION['user'].'" AND m1.user1read="no" AND users.id=m1.user2) OR (m1.user2="'.$_SESSION['user'].'" AND m1.user2read="no" users.id=m1.user1)) AND m1.id2="1" AND m2.id=m1.id group by m1.id ORDER BY m1.id DESC');

1 个答案:

答案 0 :(得分:0)

你有'在字符串的开头,也是AND m1.id2 =" 1"缺少开头的括号。另外,users.id来自哪里?

'SELECT m1.id, m1.title, m1.timestamp, count(m2.id) AS reps, users.id AS   
(
    (m1.user1="'.$_SESSION['user'].'" AND m1.user1read="no" AND users.id=m1.user2) 
    OR 
    (m1.user2="'.$_SESSION['user'].'" AND m1.user2read="no" users.id=m1.user1)
) 
AND m1.id2="1" AND m2.id=m1.id group by m1.id ORDER BY m1.id DESC');