The function mysql_create_db() is deprecated. It is
preferable to use mysql_query() to issue an sql
CREATE DATABASE
statement instead.
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$sql = 'CREATE DATABASE my_db';
if (mysql_query($sql, $link)) {
echo "Database my_db created successfully\n";
} else {
echo 'Error creating database: ' . mysql_error() . "\n";
}
?>
Il precedente esempio visualizzerà
qualcosa simile a:
Database my_db created successfully