mysql_fetch_array(MYSQL)

时间:2011-03-16 20:06:52

标签: mysql arrays fetch

我是初学者,我有错误

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\VertrigoServ\www\index.php on line 35

和代码......

$sresult = mysql_query("SELECT code, location FROM banners");
while ($row_s = mysql_fetch_array($sresult))
{
    $banner[$row_s["location"]]=$row_s["code"];
}

2 个答案:

答案 0 :(得分:1)

试试这个

$sresult = mysql_query("SELECT code, location FROM banners");
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
while ($row_s = mysql_fetch_array($sresult))
{
    $banner[$row_s["location"]]=$row_s["code"];
}

并检查错误是什么。

答案 1 :(得分:0)

查询有问题。 尝试:

$result = mysql_query("..");
if(!$result){
  echo "Query error: " . mysql_error();
}