jwmag 0 Posted June 5, 2012 Report Share Posted June 5, 2012 This error keeps occuring: Warning: mysql_fetch_array() expects parameter 2 to be long, resource given in /home/content/83/9391183/html/delete_quote.php on line 25. A portion of the code (from chapter 13): if ( isset($_GET['id']) && is_numeric($_GET['id']) && ($_GET['id'] > 0 ) ) { $query = "SELECT quote, source, favorite FROM quotes WHERE quote_id={$_GET['id']} LIMIT 1"; if ( $r = mysql_query($query, $dbc) ) { $row = mysql_fetch_array($r, $dbc); <<<<<<<<<<< LINE 25 I don't know what else to add that might be useful. No problems with adding or deleting from the database's table, nor with listing all of the entries from a table. This error seems to occur only when trying to 'SELECT' a specific row in the table and then print it to the web browser. I've tried different web browsers. No luck. I'm using an exact copy of the code that is in the book (EDIT: this is not true. i added a parameter in line 25 w/o realizing it, even after double checking that my code matched the books. the book's code is 100% error free. sorry about that.) That leads me to think it might be a configuration issue, but I don't know. I'm using a webserver and mysql database thru godaddy.com. I had this same exact error (mysql_fetch_array() expects parameter 2 to be long) when working with the examples in chapter 12. Please help. Any help is greatly appreciated! Thanks in advance. Quote Link to post Share on other sites
margaux 171 Posted June 5, 2012 Report Share Posted June 5, 2012 The second parameter for mysql_fetch_array which is optional lets you specify the type of array that is returned, either numeric or associative. Try $row = mysql_fetch_array($r); Refer to the php manual for more information on the second parameter. 2 Quote Link to post Share on other sites
jwmag 0 Posted June 5, 2012 Author Report Share Posted June 5, 2012 That was it. You know, I didn't even think of looking at the php manual.... Thanks for the fix and tip, margaux! Quote Link to post Share on other sites
jwmag 0 Posted June 5, 2012 Author Report Share Posted June 5, 2012 In my original post, I said I was using an exact copy of the code in the book, but I just realized this was not true! The code in the book is 100% correct, as expected. My apologies to the author. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.