Forum Moderators: coopster
I'm a newbie when it comes to testing PHP/MySQL files on a remote server.
Have battled through some problems and solved them; however, the following leaves me stumped:
My code is:
$mysql_database="my_database";
$mysql_username="my_user";
$mysql_password="my_password";
$link = mysql_connect($mysql_database,"33.66.99.39",$mysql_username,$mysql_password) or die ("Unable to connect to SQL server");
mysql_select_db($mysql_database,$link) or die ("Unable to select database");
The server is happy with my host IP, but returns an error:
Warning: mysql_connect(): Access denied for user: '33.66.99.39@hostserver.domain_name.net' (Using password: YES) in php_filename
In other words, it makes up a username from the IP address and server domain name, and doesn't seem to test the username and password that's specified in my PHP file.
What could be the reason? Is there something wrong with my code?
Thanks for the help
mlkarie
$my_host_username = "hostusername";
$my_mysql_username = "mysqlusername";
$my_mysql_password = "pswd";
$mysql_database="my_database";
$link = mysql_connect("localhost",{$my_host_username}_{$my_mysql_username},$mysql_password) or die ("Unable to connect to SQL server");
mysql_select_db({$my_host_username}_{$mysql_database},$link) or die ("Unable to select database");
In other words, the username should really be "hostusername_mysqlusername" and your database should be the same.
This is how it works on my server, anyway.
Birdman, your solution might be correct; I'll probably have to contact the server administrator to find out if they require the host username as well. I can't use localhost here, as already indicated by the server administrator.
Coopster, the database that I'm trying to connect to, does require a password.
Shady, the IP address is provided on the server's control panel for use to connect to the host.
Could it be a problem of different syntax on the MySQL version on their server? I was hoping to solve this without contacting the server administrator again. They are going to start thinking that I'm really dumb.
$link = mysql_connect("33.66.99.39",$mysql_username,$mysql_password) or die ("Unable to connect to SQL server");
mysql_select_db($mysql_database,$link) or die ("Unable to select database");
BTW, now that I'm through to the server, it says "Unable to select database".
It's tough being a newbie...but what do they say? If you can't stand the heat in the kitchen, get out. I'm staying in the kitchen...