Hi,
I have an issue where I get errors when I try to connect to a server that has the mysql database. I have tried using the IP address of the server with and without the port number and nothing is working; I still get an error.
This is my code:
<?php $dbhost = 'XX.XXX.XXX.XX'; // ip address of server // database connection info $dbuser = 'user'; $dbpass = 'pass'; $db = 'db'; $conn = mysql_connect( $dbhost, $dbuser, $dbpass ); mysql_select_db( $db ); if ( !$conn ) { echo "" . "ERROR" . "
"; die( 'Could not connect: ' . mysql_error() ); } else { echo "" . "WORKS" . "
"; } mysql_close( $conn ); ?>This is the error and warnings that I get:
Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://XX.XXX.XXX.XX:3306) in C:\wamp\www\test\includes\connection.php on line 11
//I know this warning is a timeout
Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\www\test\includes\connection.php on line 11
Could not connect: Access denied for user ‘’@‘localhost’ to database ‘db’
I am running on Wamp off of localhost. Could that be the problem? If it is how would you fix that?