I can’t seem to connect to mysql with a php script, even though I can connect fine with phpmyadmin. I created a user with a password, and gave it the proper priveleges for the db, but everytime it connects it dies saying access denied. I am using xampp on a windows xp box. Firewalls are all disabled, and I’ve checked the username nad password are correct. Here’s the code:
$conn=mysql_connect('localhost','westbrookc16','megadots') || die (mysql_error());
Do usernames have to be in a specific format or something?
I have a hunch that the problem here is the host you granted it to, though it’s really not more than an educated guess. If you grant access myuser@’127.0.0.1′ or the servers actual ip address, you won’t be allowed to connect using localhost as host. This is due to the fact that when "localhost" is specified as host, php will assume that you want to use a unix socket instead of network sockets, and in that context 127.0.0.1 isn’t the same as localhost.
From the manual entry for mysql_connect():
Hope this isn’t totally redundant. 🙂