猿问

为什么我的代码不能正确显示评论和回复?

这是测试代码,我知道 sql 注入以及如何修复它们。这是一个很长的问题要解释,所以我会尽力而为。


这些是我的数据库中的列


contentid (auto increments with every post, comment, and reply)

hostid (gets the value of the person who uploaded the original post)

postid (gets the value of the post, auto increments with every post)

userid (gets the value of the person who commented or replied)

date (gets the current time)

title (gets the title of the post entered by the host)

description (gets the description of the post entered by the host)

fileid (describes the type of post ex. video, picture, or blog)

commentid (auto increments with every comment)

comment (the actual comment entered by a user)

replyid (auto increments with every reply)

reply (the actual reply entered by a user)

我正在开发一个帖子系统,该系统允许用户发布内容,然后对帖子发表评论或回复帖子中的评论。我有一个名为 posts 的数据库,其中包含所有帖子的评论和回复。如果数据库中没有与帖子具有相同 postid 值的评论,则不应回显任何内容。如果数据库中没有与之前评论具有相同 postid 和 commentid 的回复,则不应回显任何内容。


换句话说,如果没有评论或回复,则不应弹出任何内容。我看到了实际的帖子,但我的数据库中有评论和回复没有显示,有什么想法吗?


森林海
浏览 91回答 1
1回答

慕尼黑8549860

看起来这部分... AND postid = 'postid' AND ...应该是... AND postid = '$postid' AND ...您的查询正在查找具有postid ==(字符串)“postid” 而不是 postid ==(值)$postid 的记录,如您所愿。
随时随地看视频慕课网APP
我要回答