I know it is not the best practice but I am working on a site for a friend and I am trying to figure out a weird issue with PHP/MySQL. I try logging in as the user root (I know this is not recommended), and the root password, which are both stored in globals. I've had the following code which was working for several years, until one day it stopped work mysteriously.
I have double checked the contents of the globals, and the username/password/database defined in the globals are correct.
Howevere I get the following error:
Could not connect: Access denied for user 'www-data'@'localhost' (using password: NO)
Is there any reason why when I try logging in as "root" it returns an error saying that I am trying to login as www-data without a password?
I have googled this for quite some time and the general result is either that I have run out of available connections from another PHP script not closing the mysql connecetion properly. However I have been unable to verify if that's the case here.
My guess is that at that point in the code, the variables you are using do not have any values, so it is trying to connect using the user name that is running your PHP script with no password. Thus one of the problems of depending on global variables.
But that's only a guess without doing some debugging to find out what the values are of those globals at that point in the code, then if not set (or wrong), tracing back through the code to see where they are defined or overwritten/unset.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation