-1

php Error I am getting is below: I have tried to see if any of the other answers posted fits my ques they do not so here it is.
This php code functioned fine on my last host server but now I am having problems with it.

mysql_fetch_row() expects parameter 1 to be resource, boolean given in showcart.php on line 17

$row = mysql_fetch_row($result);    

and 

mysql_fetch_row() expects parameter 1 to be resource, boolean given in inc_showcart.php on line 2

while($row = mysql_fetch_array($result)) 

result.php3 code

<?
//error message (not found message)
$XX = "No Record Found";
mysql_select_db("india3arts") or die( "Unable to select database");
?>
<?
//error message (not found message)
$XX = "No Record Found";
$result1 = msql_query ("select * FROM items where ".$metode." like '%".$search."%' limit 0,     1095 ");
while ($row = mysql_fetch_array($result1))
{
$variable1=$row["itemDesc"];
$variable2=$row["itemName"];
$variable3=$row["itemPrice"];
print ("this is for $row["itemDesc"];, and this print the variable2 end so on...");

}
//below this is the function for no record!!
if (!$variable1)
{
print ("$XX");
}
//end
?>
O. Jones
  • 92,698
  • 17
  • 108
  • 152

2 Answers2

0

Check $result1 before passing it to mysql_fetch_array. You'll find that it's false because the query failed.

Add code for checking the query result. Change

$result1 = msql_query ("select * FROM items where ".$metode." like '%".$search."%' limit 0,     1095 ");
while ($row = mysql_fetch_array($result1))

to

$result1 = msql_query ("select * FROM items where ".$metode." like '%".$search."%' limit 0,     1095 ");
if($result1) {
while ($row = mysql_fetch_array($result1))
gurudeb
  • 1,746
  • 21
  • 29
0

mysql_query_row(resource $result[, int $result_type = MYSQL_BOTH ] ) function's first parameter will be a resource type.

when we use mysql_query() will return resource on success, or false on error with select statements.

From your error message, it seems that mysql_query() was wrong.

Much more about mysql_query. So your can check your mysql_query() success or not first.

Anonymous
  • 11,347
  • 6
  • 32
  • 56
Liuqing Hu
  • 1,872
  • 3
  • 11
  • 15