警告:mysql_fetch_assoc() 期望参数 1 是资源,在第 36 行的 home/public_html/ 中给出布尔值
警告:mysql_fetch_assoc() 期望参数 1 是资源,在第 42 行的 home/public_html/ 中给出布尔值
在这两行代码中的第 36 行和第 42 行显示错误
请告诉我如何解决这个错误
这是我的代码
<?php
//get date
$button = $_GET['submit'];
$search = $_GET['search'];
if (!$button)
echo "Type Name";
else
{
if (strlen($search)<=3)
echo "The item you searched for was to small";
else
{
echo "You searched for <b>$search</b> <hr size='1'>";
//connect to database
mysql_connect('localhost','wh_num','password.');
mysql_select_db('wh_num');
//explode search term
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
$str = mysql_real_escape_string(substr($search_each, 0, 6));
//construct query
$x++;
if ($x==1) $construct .= "keyword LIKE '$str%'";
else $construct .= " OR keyword LIKE '$str%'";
}
$construct = "SELECT * FROM location WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "No results found.";
{
echo "$foundnum results found.<p><hr size='1'>";
while ($runrows = mysql_fetch_assoc($run))
{
//get data
$email = $runrows['email'];
$area = $runrows['area'];
echo "<b><font face=tahoma size=4 color=#600000> Name</b><b> <font face=tahoma size=4 color=#00AAFF> $search<BR></FONT></b>";
echo "<b><font face=tahoma size=4 color=#600000> Email :</b><b><font face=tahoma size=4 color=#FF9933> $email<BR></FONT></b>
<b><font face=tahoma size=4 color=#600000> Location :</b><b><font face=tahoma size=4 color=#FF0066> $area<BR></FONT></b>";
}
}
}
}
?>