gpt4 book ai didi

php - Mysql_query 错误

转载 作者:行者123 更新时间:2023-11-29 04:02:18 27 4
gpt4 key购买 nike

我对这个 mysql_query 有一个问题:

$selectNewsComments = mysql_query("
SELECT user_id, comment, time_add
FROM news_comments
ORDER BY id DESC
LIMIT " .($pageNum - 1) * $numberOfNewsInPage . ", ".$numberOfNewsInPage."
WHERE news_id = '".$nid."'
") or die(mysql_error());

这是错误信息:

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 'WHERE news_id = '18'' at line 1

谁能告诉我这个问题是从哪里来的?

最佳答案

您的 ORDER BY id DESC LIMIT 应该在 WHERE 之后

Warning: The question's sample code uses PHP's mysql extension, which was deprecated in PHP 5.5.0 and removed entirely in PHP 7.0.0.

关于php - Mysql_query 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11058137/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com