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, PECL mysql:1.0)
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().
mysql_create_db
zubrag
29-Aug-2006 03:03
29-Aug-2006 03:03
omer
20-Jun-2005 05:42
20-Jun-2005 05:42
for MySQL4.1 lib users;
as noted the function is a no-go for MySQL4.1 libs. While i do not know the logic behind this i was relieved to see that
mysql_connect ("localhost","$user","$password")
$soru = 'CREATE DATABASE '.$dbname;
mysql_query($soru);
worked just fine...
