Reputation: 11
I have wamp installed and have changed the default port (apache) to port 8888. Now, I can see the landing page when I go to http://localhost:8888/app But, when I try to connect to my database as follows:
function get_db_conn() {
$conn = mysql_connect('localhost', 'root','');
if (!$conn) {
die('Could not connect: '. mysql_error());
}
$db_selected = mysql_select_db('bargainalerts_db', $conn);
if ($db_selected) {
return $conn;
}
else {
return null;
}
}
The conn variable is always null. I can't connect to my database.I imagine it's something to do with the localhost:8888 bit. I tried setting this as the database url but it just times out. I can view the phpmyadmin control panel via the same url as above.
But I just cant get a php connection. Any help would be greatly welcolmed! Thank you.
Upvotes: 1
Views: 3607
Reputation: 151
edit httpd.conf
in Apache on wamp listen on port 80 save open browser type in localhost:80
with http://
Upvotes: 3
Reputation: 216
Check that your database if started, that you have indeed root as user and an empty password (which I doubt). Check also your MySQL port (3306 by default) and inspect the output of mysql_error()
Upvotes: 1