PDA

View Full Version : Giúp đỡ về php sql



dinhtv19
22-12-2010, 11:12
Giúp mình về lỗi này với. Đây là code của mình

<?
$result=mysql_query("select * from sanpham,nhacungcap where sanpham.MaNCC=nhacungcap.MaNCC order by MaSP desc limit 0,$SoSPHien");
$i=0;
while($row=mysql_fetch_array($result)){
$i++;
?>

Khi chạy trên localhost thi ok, nhung khi mình chạy trên sever thì lỗi :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ....../include/viewtrangchu.php on line 16

Bạn nào xem giúp mình cách khắc phục lỗi này với .

Thanks

xuandinh3081991
22-12-2010, 21:39
Đoạn này cậu nên sửa lại thế này để biết câu lệnh SQL trên sai chỗ nào vì lỗi cậu đưa ra là do sai đối số của hàm mysql_fetch_array()

$result=mysql_query("select * from sanpham,nhacungcap where sanpham.MaNCC=nhacungcap.MaNCC order by MaSP desc limit 0,$SoSPHien");

Sửa lại thành:

$result=mysql_query("select * from sanpham,nhacungcap where sanpham.MaNCC=nhacungcap.MaNCC order by MaSP desc limit 0,$SoSPHien")or die(mysql_error());