I want to establish a connection with MySql server.
My PHP code is :
<?php
$dbhost = 'testhost.com';
$dbuser = 'testuser';
$dbpass = 'testpass';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
('Error connecting to mysql');
$dbname = 'testdb';
mysql_select_db($dbname);
?>
But it show the following error:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 0 in F:\xampp\htdocs\db_connect123.php on line 6 Error connecting to mysql
In this situation i am totally confused because it work fine in localhost if i change the hostname. Please, Give me a solution how can i resolve this problem and get connect with MySql server.