jakebur01 Posted February 26, 2009 Share Posted February 26, 2009 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 More sharing options...
The Little Guy Posted February 26, 2009 Share Posted February 26, 2009 change this: $result2 = mysql_query("SELECT * FROM smith_prog_item WHERE item = $partnumber LIMIT 1"); to this: $result2 = mysql_query("SELECT * FROM smith_prog_item WHERE item = $partnumber LIMIT 1") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/147071-cannot-make-error-go-away/#findComment-772107 Share on other sites More sharing options...
Maq Posted February 26, 2009 Share Posted February 26, 2009 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"] Link to comment https://forums.phpfreaks.com/topic/147071-cannot-make-error-go-away/#findComment-772108 Share on other sites More sharing options...
jakebur01 Posted February 26, 2009 Author Share Posted February 26, 2009 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']; Link to comment https://forums.phpfreaks.com/topic/147071-cannot-make-error-go-away/#findComment-772114 Share on other sites More sharing options...
Maq Posted February 26, 2009 Share Posted February 26, 2009 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 Yes, I use single quotes for every associative array. Link to comment https://forums.phpfreaks.com/topic/147071-cannot-make-error-go-away/#findComment-772120 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.