
How can we create a database using PHP and mysql?

Hi everyone,
Using mysqlcreatedb($databaseName) we can create Mysql database.
Example :
<?php
$connection = mysql_connect("localhost","root","root");
if (!$connection)
{
die('Could not connect: ' . mysql_error());
}
if (mysql_query("CREATE DATABASE database_name",$connection))
{
echo "Database created";
}
else
{
echo "Error in creating database: " . mysql_error();
}
mysql_close($connection);
?>
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.