mysql_create_db function will not work on cPanel hosting. If you need to create database from your PHP script on cPanel hosted server then you'll need to use cPanel interface. Database creation code would look like (calling cPanel's adddb function): http://USER:PASS@HOST:2082/frontend/SKIN/sql/adddb.html?db=DB
You can download ready-made sample php script from http://www.zubrag.com/scripts/cpanel-database-creator.php
mysql_create_db
(PHP 4, PHP 5)
mysql_create_db — Crea un database MySQL
Descrizione
bool mysql_create_db
( string
$nome_database
[, resource $
identificativo_connessione
] )mysql_create_db() tenta di creare un nuovo database nel server associato all'identificativo di conmnessione specificato.
Restituisce TRUE in caso di successo, FALSE in caso di fallimento.
Example #1 Esempio creazione database MySQL
<?php
$connessione = mysql_pconnect("localhost", "utente_mysql", "password_mysql")
or die("Connessione non riuscita: " . mysql_error());
if (mysql_create_db("mio_db")) {
print ("Database creato con successo\n");
} else {
printf ("Errore nella creazione del database: %s\n", mysql_error());
}
?>
Per motivi di compatibilità con il passato, anche mysql_createdb() può essere usata. Questo è comunque sconsigliato.
Nota:
La funzione mysql_create_db() è sconsigliata. Al suo posto è preferibile usare mysql_query() per inviare un'istruzione SQL CREATE DATABASE.
Vedere anche: mysql_drop_db(), mysql_query().
zubrag ¶
6 years ago
