user1853803
user1853803

Reputation: 659

connecting to mysql from localhost when data is on server (cpanel)

I am trying to connect to mysql hosted on server. Panel used is cpanel. But i am not able to connect to the database. Running php code on local system using xamp. Error is below.

Warning: 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:\xampp\htdocs\index.php on line 2

Warning: mysql_query() expects parameter 2 to be resource, string given in C:\xampp\htdocs\index.php on line 5

Warning: mysql_error() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\index.php on line 5

Even i have put the % as the wildcard entry to allow all host but no luck. Any ideas what wrong.

Upvotes: 1

Views: 1659

Answers (1)

Manigandan Arjunan
Manigandan Arjunan

Reputation: 2265

try using port number with the domain in mysql_connect(); . The default mysql port number is 3306.

mysql_connect('yourdomain.com:3306', 'user', 'password');

Upvotes: 1

Related Questions