可能重复:PHP:警告:sort()期望参数1是数组,给定资源
我收到错误:
警告:mysql_fetch_array()要求参数1为资源,布尔值在第103行的C:\ allthewayt throughmyfolders \ www \ filterresultaat.php中给出
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);
2 回答
这意味着执行查询时出错,或者没有返回结果集,因此结果是布尔值 . 这引起了警告 .
在输入此代码段之前检查
$filterres
的值,以消除警告 .当sql请求不起作用时,通常会发生这种情况 . 语法关闭时 .
即:$ condition ='field = SOME TEXT'; $ sql =“SELECT * FROM table WHERE” . $ condition;
检查php MyAdmin中的sql请求 .