2011-10-11 96 views
0

Possible Duplicate:
PHP: Warning: sort() expects parameter 1 to be array, resource given警告:mysql_fetch_array()预计参数1是资源,布尔在等给出

我得到的错误:

警告:mysql_fetch_array()预计参数1是资源,布尔在C中给出: \ allthewaytthroughmyfolders \ WWW \ filterresultaat.php上线103

while ($regel = mysql_fetch_array ($filterres))  
    { 
      echo 
      '<tr> 
      <td>' 
      .$regel['Opleiding']. 
      '</td> 
      <td>' 
      .$regel['S_datum']. 
      '</td> 
      <td>' 
      .$regel['Duur']. 
      '</td> 
      <td>' 
      .$regel['omschrijving']. 
      '</td> 
      <td>' 
      .$regel['vergoeding']. 
      '</td> 
      <td>' 
      .$regel['Stad']. 
      '</td> 
      <td>' 
      .$regel['Straat']. 
      '</td> 
      <td>' 
      .$regel['Huisnr']. 
      '</td> 
      <td>' 
      .$regel['postcode']. 
      '</td> 
      <td>' 
      .$regel['land']. 
      '</td> 
      <td>' 
      .$regel['contactpersoon']. 
      '</td> 
      </tr>'; 
} 

这是奇怪的,因为它是一个小时前的工作。

任何人都可以帮忙吗?

编辑:

if (isset($opleiding)) 
    { $opleidingq = 'opleiding = "'.$opleiding.'" and'; } 
if (isset($duur)) 
    { 
     if($duur = 30) 
     { 
      $duurq = ' '; 
     } 
     else 
     { 
     $duurq= 'duur= "'.$duur.'" and'; 
     } 
    } 
else 
    { $duurq = ' '; 
    } 
if (isset($type)) 
    { $typeq= 'type= "'.$type.'" and'; } 

$filter = "SELECT * FROM opdracht WHERE $opleidingq $duurq $typeq gevuld ='nee';"; 

//mysql_query($filter); 

$filterres = mysql_query($filter); 
+1

您可以发布'$ filterres' var的代码吗? – Nexerus

+0

另请参阅[this](http://stackoverflow.com/questions/3899923/php-error-mysqli-num-rows-expects-parameter-1-to-be-mysqli-result-boolean-giv)或[this ](http://stackoverflow.com/questions/4988425/mysql-query-boolean-given) –

+0

尝试var_dump($ filterres)。如果它为空或只是没有查询结果,则查询失败。也许WHERE语句可能会引发错误,请尝试删除它! – Anonymous

回答

1

这意味着,当执行查询,或没有返回结果集,因此,结果是一个布尔发生了错误。这导致了警告。

在输入此代码段之前,请检查$filterres的值以摆脱警告。

0

当sql请求不起作用时,通常会发生这种情况。语法关闭时。

例如: $ condition ='field = SOME TEXT'; $ sql =“SELECT * FROM table WHERE”。$ condition;

检查php MyAdmin中的sql请求。

相关问题