荔园晨风上不了:网页中使用SQL语句出现错误

来源:百度文库 编辑:高校问答 时间:2024/05/05 18:48:05
---------------------------------------------------------------
//网站分类数目统计
$query = $db->query("SELECT * FROM {$tablepre}forums WHERE type='forum'");
while($forum = $db->fetch_array($query)) {

$aposts1+=$forum['threads'];
$aposts2+=$forum['posts'];
$todayposts += forumtodayposts($forum);

}
--------------------------------------------------------------
中间这段代码哪里有问题啊?

还有一段,详细请见
http://www.discuz.net/thread-347148-1-1.html
问题更新在3楼
我是用在http://zhongruan.li/bbs/ 的首页调用

这里是mysql的数据库吧
如果是这样的话 问题可能出现在type='forum'
这里type是系统的关键字
在sql server中关键字用 中括号 "[]" 在mysql中关键字用 “`”【这个` 不是单引号 是在主键盘区 数字1前面那个】
先写成这样试试吧 `type`='forum'
你可以再检查一下其他的sql语句中有没有这样关键字 有的话改成那样的 至于mysql的关键字随便找个mysql的手册都有