I have spent the last two hours trying to work out why I'm getting a *Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\modify.php on line 12.* Here's the full PHP code on paste bin.

I can't seem to figure out how to solve it. Here's how I'm supplying the id value http://localhost/modify.php?id=2

link|improve this question

feedback

2 Answers

up vote 1 down vote accepted

Seems like $result is a boolean, most likely false indicating that the query failed for one reason or another. Change line 11:

$result = mysql_query($q) or die(mysql_error());

Mandatory plug for PDO or other superior DB wrapper and query sanitation (SQL Injection) especially from GET .. ack!

link|improve this answer
+1 for "PDO or other superior DB wrapper and query sanitation". $_GET ack indeed. – Charles Sprayberry Jul 17 '11 at 16:01
Thanks. Your suggested code has helped solve the problem. The table name was wrong which I could spot. Adding the error message was all I need. Thanks for the quick response. Could you point me to a resource where I can learn more about PDO or other superior DB wrapper? – Helen Neely Jul 17 '11 at 16:02
Just google PDO or look up PDO in the manual at php.net – Explosion Pills Jul 17 '11 at 16:03
@Helen Neely Here's the official PHP docs on PDO – Charles Sprayberry Jul 17 '11 at 16:07
Thanks guys, you've all been very helpful. I appreciate it a great deal. And thanks to you @Charles for the awesome link. – Helen Neely Jul 17 '11 at 16:14
feedback

There is an error being returned from mysql_query. Check out mysql_error for mor information.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.