gpt4 book ai didi

php - 获取最新的新闻发布数据库

转载 作者:行者123 更新时间:2023-12-01 00:04:41 26 4
gpt4 key购买 nike

我正在尝试从我的数据库中获取最新的帖子。如果我运行以下代码,我会收到以下消息:

“无效查询:您的 SQL 语法有误;请查看与您的 MySQL 服务器版本对应的手册,了解在第 2 行的‘TABLE newsposts ORDER BY newsposts.post_id DESC’附近使用的正确语法”

<?php
$getPosts = mysql_query("SELECT newsposts.post_id, newsposts.post
FROM TABLE newsposts
ORDER BY newsposts.post_id DESC
LIMIT 1") or die('Invalid query: ' . mysql_error());
while($getPosts_Array = mysql_fetch_array($getPosts)){

$post_id = $getPosts_Array['post_id'];
$post = $getPosts_Array['post'];

echo "
$post;


";
}
?>

最佳答案

去掉 SQL 语句中的“TABLE”,因为 FROM 子句假定一个表。

关于php - 获取最新的新闻发布数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19815534/

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