No connection could be made to the database.
ERROR: ".mysql_error(); exit;
}
function create_db()
{
echo "Could not locate the database. attempting to create it.";
$sql_file = "mysql.sql";
if (file_exists($sql_file))
{
$fh = fopen($sql_file,"r");
$sql = fread( $fh, filesize($sql_file) );
$result = mysql_query($sql);
if (mysql_affected_rows() != 0)
{
echo "
Database created sucessfully. please click here to continue.
";
?>
}
else
{
echo "
Database could not be created. Please check the your permissions and try again or execture mydb.sql manually.
";
}
}
else
{
echo "
could not locate mysql.sql. please be sure that it is in the same directory as this script if you want it to create itself.";
echo "
or you can manually execute it through the mysql console if you do not wish to automate the creation process.
"; exit;
}
}
if (db_connect())
echo "everything is fine.";
else
create_db();
?>