Jump to content

Recommended Posts

ok so this function is giving me this.


Warning: mysql_query() [function.mysql-query]: Access denied for user 'kabooc'@'localhost' (using password: NO) in /home/kabooc/public_html/func.lib.php on line 5

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kabooc/public_html/func.lib.php on line 5

 

the code is:

 

<?php

function fetch($query) {
return mysql_query(mysql_fetch_array($query));

}?>

any help debugging this would be appreciated ;D

 

Link to comment
https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/
Share on other sites

that user has all permissions for that database :(

 

Are you sure?  Cause that error usually means 1 thing...

 

Could you log in to mysql with root and do "show users;" (or w/e the command is) and see if kabooc is set up with all privileges for your local server?

Does the query work outside of the "fetch" function you created?

 

Before you use the "fetch" are you getting a good connection to the database. Honestly if the query works outside than you should try passing the dblink or making it global to the function and using that.

 

But if the mysql_query does not work outside of the function the issue lies within your database username/password privileges.

1) Are you using a "canned script" (modules) for some of this?

 

2) Are you on a "shared" enviorment?

 

3) If you're uploading to #2, and you don't have the ability to "CHMOD", you'd run into this.

 

4) If you can't "change" r-w perm's w.it..this would possibly be it, again?

 

 

1) Are you using a "canned script" (modules) for some of this?

 

2) Are you on a "shared" enviorment?

 

3) If you're uploading to #2, and you don't have the ability to "CHMOD", you'd run into this.

 

4) If you can't "change" r-w perm's w.it..this would possibly be it, again?

 

 

 

Hes not doing a file upload. He is just trying to query from his database....

could mysql_close($connection) kill it even if $connection is defined to another database. ???

 

Possibly, if you are using multiple connections, I would highly suggest using $connection in the mysql_query as the second parameter.

 

<?php

function fetch($query) {
global $connection;
return mysql_fetch_array(mysql_query($query, $connection));

}?>

 

Also I just noticed that you had the fetch_array in the wrong spot, and also note that without the while loop this will only ever return the first array value.

 

function fetch($query) {
    global $connection;
    $result = mysql_query($query, $connection);
    while ($row = mysql_fetch_array($result)) {
          $return[] = $row;
    }
    return $return;
}

 

That will return the multi-dimm array with the results.

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.