Jump to content

Recommended Posts

I have looked for case sensitivity, added quotes, and removed quotes and I cannot make this error go away.

 

PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in

 

 else
   {
                           
$result2 = mysql_query("SELECT * FROM smith_prog_item WHERE item = $partnumber LIMIT 1");
while ($row2 = mysql_fetch_assoc($result2)) {
   																if($row2["type"]=="NGK")
															{ $c17="100"; $c18="$level6";}


															elseif
															($row2["type"]=="OTHER")
                 												{ $c11="$level6"; $c12="$level6"; $c13="$level6"; $c14="$level6"; $c15="$level6"; $c16="$level6"; }
   
										}
  
   
   } 

 

Also, this is within another while loop.

Link to comment
https://forums.phpfreaks.com/topic/147071-cannot-make-error-go-away/
Share on other sites

Debugging tips, echo $sql to make sure you're passing in the correct string for your query, if the mysql_query cannot execute it will kill the script and output a descriptive error message.

 

Change this:

 

$result2 = mysql_query("SELECT * FROM smith_prog_item WHERE item = $partnumber LIMIT 1");

 

to this:

 

$sql = "SELECT * FROM smith_prog_item WHERE item = '$partnumber' LIMIT 1";
echo $sql;
$result2 = mysql_query($sql) or die(mysql_error());
while ($row2 = mysql_fetch_assoc($result2)) {

 

 

Also use single quotes in your arrays: 

 

$row2["type"] 

 

to this:

 

$row2["type"]

ha ha... it echoed the $sql out 7,000 times. Thank you. It fixed it.

 

When setting $_SESSION and stuff like that, do you use single quotes there too?

 

Ex.

$_SESSION['sample'];

 

 

Oh lol, didn't know it was in a loop  :P

 

Yes, I use single quotes for every associative array.

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.