I was banging my head on this PHP error:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'warnerb'@'localhost' (using password: NO) in /home/warnerb/public_html/ivwp/index.php on line 24
That error typically means the username and/or password is wrong, but I echo’d the contents of the DB variables and they were correct.
However, when I hard-coded those same values into the PHP code IT WORKED!
Here’s the chunk of code in question:
mysql_connect($hostname,$dbusername, $dbpassword) OR DIE ("Unable to connect to database! Please try again later.");
What I did to check the values of $hostname, $dbusername, and $dbpassword was this:
echo $hostname . "<p>";
echo $dbusername . "<p>";
echo $dbpassword . "<p>";
I could see the variables were set to the correct values, but unless I hardcoded things I continued to get the error message.
Here’s how I fixed it…
…and that fixed the problem!
Apparently my understanding of what require_once() does is lacking. I suspect the problem is one of scope, but since the values would echo correctly I’m just completely stumped.
However, the code now works so I’m going to let it alone for now.