SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error creating database

    I can't figure out why I can't create a database :?

    I host 2 phpBB2 forums on my website and a CMS (phpNuke) as well as messing around with a lot of phpBB precompiled scripts (phpChat, phpCommerce, etc.)

    But how would I go about creating a database?

    The way I did it was to mysql_create_db("test") but that gets an error "Call to undefined function: mysql_create_db()", however mysql_connect and other mysql commands work. I also tried mysql_query("CREATE DATABASE test") and that doesn't work either. I know that it can be created though because I have phpBB2 installed with MySQL.

    I know that MySQL is supported in the php by running phpinfo().

    What could the problem be?

    The code is (but I've also tried other ways and get no result creating a db):

    Code:
    <?php
    $link = mysql_connect("localhost");
    if (! $link)
    die("Couldn't connect to MySQL");
    //create database
    mysql_create_db("mydatabase");
    mysql_close($link);
    ?>

    --pyius

  2. #2
    SitePoint Evangelist nick0161's Avatar
    Join Date
    Oct 2004
    Location
    australia
    Posts
    424
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    don't you have to include username and password of the mysql db?

    like $link=mysql_connect("localhost","root"(if your using root as username),"password"(if any);

  3. #3
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know your server setup, but typically on a shared server or on a CPanel server, a user doen't have permissionsto create a database.

    So, it is usual for phpMyAdmin (or similar) to be present to allow you to create the db manually.

    Mike

  4. #4
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've tried with user/pass in the connect, it can connect fine, but it can't create the db.

    I do have a CPanel setup. But like I said, I have phpBB and that can create the db, so why can't this?

    EDIT: Ok, I might have figured it out. I probably have to create the database because, when i set up my phpBB, the database was created by the script engine that CPanel has implemented. Thanks anyways.


    --pyius


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •