首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

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

2012-04-08 
php错误:You have an error in your SQL syntax 急!!!!!$sqlselect id,title,type_id,time from news l

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."<br/><br/>".mysql_error());; 
while ($row=mysql_fetch_array($result)) 
{  
?> 
<tr> 
<td bgcolor="#E0EEE0" height="25px"><div align="center"> 
<?php echo $row[1]?> 
</div></td> 
<td bgcolor="#E0EEE"><div align="center"> 
<?php echo $row[2]?> 
</div></td> 
<td bgcolor="#E0EEE"><div align="center"> 
<?php echo $row[3]?> 
</div></td> 
<td bgcolor="#E0EEE"><div align="center"> 
<a href="newsChange_ok.php?id=<?php echo $row[0] ?>">修改</a>&nbsp;&nbsp;&nbsp;<a href="#">删除</a>
</div></td> 
</tr>  



直接上代码!!!!!错误提示: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}";

看看.

热点排行