Create a MySQL database from PHP
This example assumes you have MySQL and PHP correctly installed on your server .
First well take a look at the code then we will explain it to you .
Code :
<?php
$result = mysql_create_db("mydb");
if ($result == false)
echo ("failure to create database");
?>
This is quite simple we deal with the first line $result = mysql_create_db("mydb"); , this creates a database called mydb using the mysql_create_db function , this is stored in the variable $result .
The next lines
if ($result == false)
echo ("failure to create database");
are used to display an error message if for some reason the database was not successfully created .