So I’m having an issue connecting to a mySQL database I created on my local host using XAMPP. The DB itself is set up fine on 127.0.0.1, but I had to use port 8000 (instead of 80) to get it to start in XAMPP.
$con = mysql_connect("localhost:8000","","");
if (!$con) {
die('Connection failed.' . mysql_error());
}
The above doesn’t work, the browser times out after a few seconds saying it cannot display the webpage (note that it doesn’t give the die message). I have also tried 127.0.0.1:8000 but no luck. Creating a user in phpMyAdmin and entering the credentials didn’t achieve anything either.
If I take out the port and just use:
$con = mysql_connect("localhost","","");
This connects, but I can’t seem to select my database because I don’t think it’s connecting to the right server!
Any ideas? Thank you in advance!
You better of using PDO
http://www.php.net/manual/en/pdo.construct.php