Maybe the OP asked about how create a database using PHP and MySQL, not create a database in cPanelIf you're having a cPanel. You can easily create a Database in PHP using MySQL/phpMyAdmin from the panel.
I do a research and here's codes you can use to create a database using php.Hi All
I am How can we create a database using PHP and MySQL?
Only expert ...
Thanks
<?php
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'rootpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
$sql = 'CREATE Database test_db';
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not create database: ' . mysql_error());
}
echo "Database test_db created successfully\n";
mysql_close($conn);
?>
<?php
$link=mysqli_connect("localhost","Username","password","dbname");
if(!$link)
{
die('Could not connect: ' . mysqli_error($link));
}
else
{
if(myqli_query($link,"CREATE DATABASE database_name"))
{
echo "Success";
}
mysqli_close($link);
}
?>