I am trying to connect to my MySQL database on my online server through PHP on my localhost.
$con = mysql_connect("$hostname", "$username", "$password");
if (!$con) {die('Could not connect: ' . mysql_error());}
mysql_select_db($databasename, $con);
When I upload the script to the server, it connects to the database perfectly. However, when I load the script on my localhost, it will not connect to the online database. I disabled my firewall to make sure it is not blocking it.
Is this connection correctly formatted correctly? Any other suggestions?
source
share