Maison  >  Article  >  développement back-end  >  php异常:You have an error in your SQL syntax; 急

php异常:You have an error in your SQL syntax; 急

WBOY
WBOYoriginal
2016-06-13 13:39:25874parcourir

php错误:You have an error in your SQL syntax; 急!!!!!

$sql="select id,title,type_id,time from news limit $offset,$Page_size where type_id=".$type_id; 
echo $sql;
$result=mysql_query($sql) or die($sql."

".mysql_error());; 
while ($row=mysql_fetch_array($result)) 
{  
?> 

 
 
 
 
 
 
 
 
 
 
 
修改   删除
 
 



直接上代码!!!!!错误提示: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 ''0,6' where type_id=21' at line 1 


请问怎么回事啊??????????????????急!!!!!!!!!!!!!!!!!!

------解决方案--------------------
select id,title,type_id,time from news limit $offset,$Page_size where type_id=".$type_id;

修改成

select id,title,type_id,time from news where type_id=".$type_id." ORDER BY ID DESC LIMIT {$offset},{$Page_size}";

看看.
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn