PHP显示错误的用户名

时间:2017-04-17 20:01:00

标签: php mysql

我在一个安全的博客上工作,一旦用户点击了更多按钮,我就会在单独的页面中显示一个特定的帖子。这个单独的页面包括注册用户的评论。我的问题是编写评论的用户的名称与实际用户不匹配,而是显示撰写帖子的用户的名称。我的SQL查询:

$comsql="SELECT c.*,u.name FROM posts p JOIN users u ON p.user_id=u.id"
    ." JOIN comments c on p.id=c.post_id ORDER BY commentdate DESC"; 

我的回声:]

撰写者: ,开启:“>编辑评论|”>删除评论

2 个答案:

答案 0 :(得分:0)

是的,这就是你的要求:

There is no procedure with the name apoc.date.parseDefault registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

你应该有这样的事情:

ON p.user_id=u.id

在您的SQL查询中,您匹配帖子的用户而不是评论的用户。您在ON c.user_id=u.id 表格中有user_id字段吗?

答案 1 :(得分:0)

可能,注释和用户表都有名称字段。解决这个问题;

将查询更改为:

$comsql="SELECT c.*,u.name AS username FROM posts p JOIN users u ON p.user_id=u.id"
    ." JOIN comments c on p.id=c.post_id ORDER BY commentdate DESC"; 

如果不起作用,请发表评论

相关问题