Hello,
I have a wamp server, and have created a database and table (users) in phpmyadmin. I can connect to the server via php, but then I cannot connect to the database. The code I'm using is below:
<?php
$username = "";
$password = "";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
$selected = mysql_select_db("homegame",$dbh)
or die("Could not select db");
// other stuff here
mysql_close($dbh);
?>
I get the output:
Connected to MySQL
Could not select db
Can anyone tell me what the issue is or give me alternative code? Please make a note if the question is too vague.
Thanks,
Legs
Tags: