Have an account? Sign in
Login  Register  Facebook
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean
$z = "Model LIKE '%" . $name .  "%' AND";
$f = "Condition =$coni AND";
$v = "Country =$country AND";
$g = "length BETWEEN $L1 AND $L2";
$s = "AND powerplant='$powerplant'";

		if ($country == "0")
		{$v = "";}

		if ($powerplant == "a")
		{$s = "";}
		
		

	$sql = "select * FROM boats WHERE $z $f $v $g $s LIMIT $startpoint,$perpage;";
	$result =mysql_query($sql);
	

echo "<table width = '60%' border='0' cellspacing = '0' >
<tr>
<th>Model</th>
<th>Length</th>
<th>Engine</th>
<th>Powerplant</th>
<th>Price</th>
<th>Country</th>
<th>Boat ID</th>
<th>CONDITION</th></th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['Model'] . "</td>";
  echo "<td>" . $row['length'] . "</td>";
  echo "<td>" . $row['engine'] . "</td>";
  echo "<td>" . $row['powerplant'] . "</td>";
  echo "<td>" . $row['price'] . "</td>";
	
	{$c=$row['Country'];  
	$sql2 = "select * FROM countries WHERE CountryID = $c";
	$result2=mysql_query($sql2);

	while($row2 = mysql_fetch_array($result2)){
	echo "<td>" . $row2['countrylist'] . "</td>";}}
  
  
  
  echo "<td>" . $row['BoatID'] . "</td>";
  echo "<td>" . $row['Condition'] . "</td>";
	
  $joe = $row['BoatID'];
  echo "<td> <form  method='get' action='details.php?go'  id='searchform2'><input type='hidden' name='hideID' value = '$joe'/><input type='submit' name='submit' value='more info'/></form></td>";
  echo "</tr>";
  
  echo "<tr>";
  echo "<td colspan = '8'> " . '<hr />' . "</td>";
  echo "</tr>";
	
	}
echo "</table>";



This code worked fine. However when I included $f in the search query the following error resulted:Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean in ....


What is the problem pls?
Started: September 21, 2011 Latest Activity: September 21, 2011 query

ok use echo $sql; and let me see what will return
September 21, 2011

select * FROM boats WHERE Model LIKE '%%' AND Condition = AND length BETWEEN 0 AND 900000 LIMIT 0,4;
September 21, 2011

the error is 'Condition = ' there is no value of it
September 21, 2011


September 21, 2011

When I add any other queries, I get the same error code... Warning: Mysql_fetch_array() Expects Parameter 1 To Be Resource, Boolean In .... Can't understand why!!!!!
September 21, 2011

2 Answers
your problem from \'\' please use the code of Gamal exactly seee Condition = on must be Condition = \'on\'

Posted: MacOS
In: September 21, 2011

this is the best way to do that
$reords = array();
if(isset($name)){
    $reords[] = \"Model LIKE \'%\" . $name .  \"%\'\";
}

if(isset($coni)){
    $reords[] = \"Condition = \'$coni\'\";
}

if(isset($country)){
    $reords[] = \"Country = \'$country\'\";
}

if(isset($L1) and isset($L2)){
    $reords[] = \"length BETWEEN \'$L1\' AND \'$L2\'\";
}

if(isset($powerplant)){
    $reords[] = \"powerplant=\'$powerplant\'\";
}
$sql = \"select * FROM boats WHERE
     \".implode(\' and \', $reords).\"
         LIMIT $startpoint,$perpage;\";

Posted: Gamal
In: September 21, 2011

thanks will try it out...
September 21, 2011

Hi, I've tried this out... but the problem still persists!!! :-(
September 21, 2011

this mean the problem from the sending the variables let me see the echo $sql;
September 21, 2011


September 21, 2011

The above is the echo $sql... it looks ok...but it still won't work!!!!
September 21, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer