I'm having some problems selecting my database after I have successfully connected to it in PHP.
I keep getting the message "Warning: mysql_select_db(): 3 is not a valid MySQL-Link resource in /home/username/public_html/db/display.php on line 18
Can't use database :"
Here's my code if you can help:
CODE
<?
# Select database
$db_selected = mysql_select_db($db_name, $con);
if (!$db_selected) {
die ('Can\'t use database : ' . mysql_error());
}
echo 'Graham, your database has been selected successfully';
?>
# Select database
$db_selected = mysql_select_db($db_name, $con);
if (!$db_selected) {
die ('Can\'t use database : ' . mysql_error());
}
echo 'Graham, your database has been selected successfully';
?>
$dbname is my database name and $con is the variable which holds my database connection details used in the connection page which works fine.
I can connect to the database fine but am unable to select it prior to running a query to show all data contained in one of its tables.
Can someone spot what's wrong in the above code, please?
Thanks!
