So i keep getting this error when trying to connect to my database remotely. The strange thing is it works for like 1/2 query(s) a minute but then after those query's it stops working and gives this error message. This just started happening randomly, before it used to work fine for many querys per second.
Details:
- Im using xampp to host my database
- The details to connect to the database are correct
Any ideas what might be happening?
Example of code (This is the code which I using to test the connection):
$connection = mysql_connect('IP', 'DATABASE PASSWORD', 'PASSWORD', 'DATABSE NAME') or die(mysql_error());
if (!$connection)
die('Not connected : ' . mysql_error());
$db_selected = mysql_select_db('DATABSE NAME', $connection);
if (!$db_selected)
die ('Can\'t use : ' . mysql_error());
$string = mysql_query("SELECT * FROM `characters` WHERE `name` LIKE 'gil'") or die(mysql_error());
if($result = mysql_fetch_assoc($string))
echo $result['name'];
Full Error code:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'IP' (4) in /vhosts/DOMAIN/httpdocs/test.php on line 1
Can't connect to MySQL server on 'IP' (4)