This is my code, on a remote server:
$username = 'myuser';
$password = 'password';
mysql_connect('localhost', $username, $password) or die ('blah blah blah');
And occasionally, it gives me this error:
Access denied for user 'myuser'@'localhost' (using password: NO)
This error persists for around 6 minutes, then fades away
Why does this happen? How can I fix it?
P.S.: Please don't worry about me using mysql_*
. I also use mysqli, and the problem also occurs. Please help.
Since, the error you are receiving is
Access denied for user 'myuser'@'localhost' (using password: NO)
and not
blah blah blah
as defined in the die ('blah blah blah');
segment; the error is not because of your connection to MySQL server.
This is most probably because the user myuser does not have PRIVILEGES
to perform the task you are asking it to do(may be DELETE
, may be UPDATE
or may even be SELECT
)