Jump to content

mysql_fetch_assoc()


Shazer2

Recommended Posts

I am receiving this error:

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/shannon/public_html/booter/inc/classes/class.db.php on line 17

For the function:

function fetch_array($query) {
    $array = mysql_fetch_assoc($query);
    return $array;
}

 

Why would I receive that error, if I am just passing a variable? Not a resource or boolean?

 

Thanks.

Link to comment
Share on other sites

$query = $db->select("boot", "id, uid", "id=1");

It's a very great line! ;) But why are you sure that all people knows the internal part of this function, it's parameters and so on?

 

It's not a request, it's a call to the function that could do it and send to MySQL - I don't know, I can suggest it only.

Link to comment
Share on other sites

OK... You might have a query

 

SELECT id,uid FROM `boot` WHERE id=1

 

Did you try to execute it from phpmyadmin? It seems that something is wrong it this query. Function mysql_error() could be useful for you to see exactly what is wrong. You may try to use it just after you make a call to function select().

Link to comment
Share on other sites

I just realised a few things, firstly I wasn't selecting a database and secondly I had the wrong table name. I corrected both but I'm still getting this error.

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/shannon/public_html/booter/inc/classes/class.db.php on line 18

Link to comment
Share on other sites

I figured it out, I guess I wasn't connecting OR selecting a database as in the construct for my DB class I was doing.

function __construct() {
return self::connect();
return self::select_db();
}

 

Instead of

function __construct() {
self::connect();
self::select_db();
}

 

I changed it to the second code, and now everything works fine.

 

Thanks for all the help!

 

Link to comment
Share on other sites

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.