Jump to content

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


Gingechilla

Recommended Posts

I have read through and tried the results of questions like this but found nothing that helped.

 

// If current page number, use it 
// if not, set one! 

if(!isset($_GET['page'])){ 
   $page = 1; 
} else { 
   $page = $_GET['page']; 
} 

$search=$s;
$search=$_POST["search"];

$CATSEARCH=$CAT;
$CATSEARCH=$_POST["CAT"];
$CATPAGE=$_POST["CAT"];



// Define the number of results per page 

if($mR > 50){
$max_results = 50;
} else { 
$max_results = $mR;	
} 

// Figure out the limit for the query based 
// on the current page number. 
$from = (($page * $max_results) - $max_results); 

// Perform MySQL query on only the current page number's results 

$sql = "SELECT * FROM items WHERE title LIKE snowball ORDER BY title LIMIT 10";
$query = mysql_query($sql);
while($r = mysql_fetch_array($query)); { [color=red]<<<<<<<<<<<<<<<<< LINE 76 >>>>>>>>>>>>>>[/color]

  $title=$r["title"];
  $code=$r["code"];
  $message=$r["message"];
  $no problem=$r["no problem"];
  $cat1=$r["cat1"];
  $cat2=$r["cat2"];
  $cat3=$r["cat3"];
  $id=$r["id"];


   // Build formatted results here. 
  echo "$title<p>";
}

 

I get this error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /results.php on line 76

 

I have checked the names of the tables and fields over and over, I have also tried the "die" result and that did not tell me anything.

Link to comment
Share on other sites

That just shows me what I asked to search the database for :--/

Exactly! It shows you the exact query being called after the variables have been filled into the $sql string. This can be helpful debugging now and then as you may unexpectedly be changing the contents of one variable without realising it - I've done this when tired.

 

What do you mean "no idea why it works like this though"?

 

Sorry for late reply, had my head in the javascript forum.

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.