PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mysql_data_seek> <mysql_connect
Last updated: Fri, 18 Jul 2008

view this page in

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().



add a note add a note User Contributed Notes
mysql_create_db
zubrag
29-Aug-2006 12:03
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
omer
21-Jun-2005 02: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...

mysql_data_seek> <mysql_connect
Last updated: Fri, 18 Jul 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites