Movatterモバイル変換


[0]ホーム

URL:


    mysql_data_seek »
    « mysql_connect

    mysql_create_db

    (PHP 4, PHP 5)

    mysql_create_dbCreate a MySQL database

    Warning

    This function was deprecated in PHP 4.3.0, and itand the entireoriginal MySQL extension was removed in PHP 7.0.0.Instead, use either the actively developedMySQLi orPDO_MySQL extensions.See also theMySQL: choosing an API guide.Alternatives to this function include:

    Description

    mysql_create_db(string$database_name,resource$link_identifier = NULL):bool

    mysql_create_db() attempts to create a new database on the server associated with the specified link identifier.

    Parameters

    database_name

    The name of the database being created.

    link_identifier

    The MySQL connection. If thelink identifier is not specified, the last link opened bymysql_connect() is assumed. If no such link is found, itwill try to create one as ifmysql_connect() had been calledwith no arguments. If no connection is found or established, anE_WARNING level error is generated.

    Return Values

    Returnstrue on success orfalse on failure.

    Examples

    Example #1mysql_create_db() alternative example

    The functionmysql_create_db() is deprecated. It is preferable to usemysql_query() to issue an sqlCREATE 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";
    }
    ?>

    The above example will outputsomething similar to:

    Database my_db created successfully

    Notes

    Note:

    For backward compatibility, the followingdeprecated alias may be used:mysql_createdb()

    Note:

    This function will not be available if the MySQL extension was built against a MySQL 4.x client library.

    See Also

    Found A Problem?

    Learn How To Improve This PageSubmit a Pull RequestReport a Bug
    add a note

    User Contributed Notes

    There are no user contributed notes for this page.
    To Top
    and to navigate •Enter to select •Esc to close •/ to open
    PressEnter without selection to search using Google

    [8]ページ先頭

    ©2009-2025 Movatter.jp