警告:mysql_fetch_array():

时间:2011-10-15 14:58:39

标签: php

是否有可能以不同的方式重写此脚本部分?因为它在我的本地主机中工作正常,但是当我将它移动到托管时它显示:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /***************************.php on line 67
<? 
$query = "SELECT COUNT(*) as num FROM $tableName"; 
//////Below error line
$total_pages = mysql_fetch_array(mysql_query($query)); 
/////////////
$total_pages = $total_pages['num'];
?>

1 个答案:

答案 0 :(得分:-1)

你可以这样做:

$query = "SELECT COUNT(*) FROM $tableName";

$total_pages = mysql_result(mysql_query($query), 0);

请参阅PHP: mysql_result()