我已经找到方法了:
在 $query = 'select * from article where cid='.$cid.'order by aid desc limit 20' 中
把 '.$cid.' 改为:"'.$cid.'" 
上次也遇到这个问题,我不知道这是什么原理$cid 的值是数值,为什么还要在前面加双引号呢,还是其他的原因啊

解决方案 »

  1.   

    'select * from article where cid='.$cid.'order by aid desc limit 20'
    应写作
    'select * from article where cid='.$cid.' order by aid desc limit 20'
    不然 order 与前面的 $cid 黏在一起了
      

  2.   

    cid跟后面的order之间要有空格 不然都当成cid的值了 语法有误
      

  3.   

    $query = “select * from article where cid='$cid' order by aid desc limit 20”
    最外层用双引号,里面不用拼接