Jump to content
Larry Ullman's Book Forums

Error Mysequl_Fetch_Arrary () Expects Parameter 2 To Be Long

Recommended Posts

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.

Link to post
Share on other sites

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.

  • Upvote 2
Link to post
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...