Jump to content

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result reso


devan

Recommended Posts

Hi guys, for the life of me, what am I doing wrong, I cannot figure out this one, getting this error :

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ......... search.php on line 36

 

my code :

 


$start = ($page-1)*$per_page;
$sql = "SELECT productId, productCode, image, name, price, stock_level FROM inventory WHERE productCode LIKE '%".$searchp."%' OR name LIKE  '%".$searchp."%' AND Seller_ID = '" . $_SESSION['SESS_SELL_ID'] . "' order by name limit $start,$per_page";
$rsd = mysql_query($sql);


	<?php


	while($row = mysql_fetch_array($rsd))  // ERROR OCCURS HERE : line 36
	{

		$idpc=$row['productId'];
		$idc=$row['productCode'];
		$idi=$row['image'];
		$idn=$row['name'];
		$idp=$row['price'];
		$ids=$row['stock_level'];

	?>

 

all help appreciated as always.

 

 

My guess is that this code is OUTSIDE of the "<?php" bracket..

 

"$start = ($page-1)*$per_page;

$sql = "SELECT productId, productCode, image, name, price, stock_level FROM inventory WHERE productCode LIKE '%".$searchp."%' OR name LIKE  '%".$searchp."%' AND Seller_ID = '" . $_SESSION['SESS_SELL_ID'] . "' order by name limit $start,$per_page";

$rsd = mysql_query($sql);"

 

 

My guess is that this code is OUTSIDE of the "<?php" bracket..

 

"$start = ($page-1)*$per_page;

$sql = "SELECT productId, productCode, image, name, price, stock_level FROM inventory WHERE productCode LIKE '%".$searchp."%' OR name LIKE  '%".$searchp."%' AND Seller_ID = '" . $_SESSION['SESS_SELL_ID'] . "' order by name limit $start,$per_page";

$rsd = mysql_query($sql);"

 

Hi, no, the code in within the PHP tags, I only wish it was that easy !  :'(

If you search for (the keywords in) that error message, you will find that it generally means that your query failed due to an error of some kind. There are a couple of other possibilities, depending in what your actual code is (it always pays to post enough of your actual code the reproduces the problem.)

 

For debugging purposes, use the following for your mysql_query statement -

 

$rsd = mysql_query($sql) or die("Query failed: $sql<br />Error: " . mysql_error());

Hi,

 

I added the code you provided ( thanks ) to check the error, this is what MySQL error I get :

 

Query failed: SELECT productId, productCode, image, name, price, stock_level FROM CubeCart_inventory WHERE productCode LIKE '%gold%' OR name LIKE '%gold%' AND Seller_ID = '25' order by name limit -35, 35

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-35, 35' at line 1

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.