这是我的一段代码:
if($validentry==0){
$sql="select blog_entries.*, blog_categories.cat from blog_entries, blog_categories where blog_entries.cat_id=blog_categories.id order by dateposted DESC LIMIT 1;";

}
else{//否则显示用户选中的文章
$sql="select blog_entries.*, blog_categories.cat from blog_entries, blog_categories where blog_entries.cat_id=blog_categories.id and blog_entries.id= " . $validentry . " order by dateposted DESC LIMIT 1;";
}这个代码应该没有错,可浏览器总是显示如下:
invalid query: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 'by dateposted DESC' at line 1
这是怎么回事,求各位有经验的人帮帮忙!!!!!!

解决方案 »

  1.   

    sql语句错误,你把sql语句输出看一下
      

  2.   

    无效的查询:您在您的SQL语法错误,检查对应的手册,为正确语法你的MySQL服务器版本才能使用附近有由dateposted倒序'行1 你的两个表都有 dateposted 字段吧?
      

  3.   

    你将你的SQL查询语句放到数据库里面去执行,如果能正常显示出结果,说明你的SQL语句没有错误,如果提示错误,说明的你的SQL语句存在错误