I am trying to create a database if the database is not present, but it shows some error.
This the code that I am using:
{
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(!$conn)
{
die('Failed to connect to server: ' . mysql_error());
exit;
}
$db_selected = mysql_select_db($dbname);
if(!$db_selected)
{
$db_selected = " CREATE DATABASE $dbname ";
}
}
This is the error that i get:
mysql_fetch_row() expects parameter 1 to be resource, boolean given on line 2 Reading one value from empty results