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.

 

 

Link to comment
Share on other sites

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);"

 

 

Link to comment
Share on other sites

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 !  :'(

Link to comment
Share on other sites

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());

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.