SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2000
    Location
    England
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just creating an installation script with db_mysql from phplib. I have got all the tables created etc but what i need to do is the first bit.

    Basically, i want it to do something like this:

    i) attempt to connect to the db server. If that fails give message.

    ii) check to see if the database is there. If not attempt to create it. If that fails give error message else continue.

    iii) if datbase is there, continue.

    So basically what i don't know how to do using phplib is check for a database's existance and also creata a database. do you just do $query = CREATE database blah for that bit? if so how do you check for the existance of a database and prevent a message error if it is not there?

    thanks.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The easiest way to achieve this, is
    PHP Code:
    $db->query("CREATE DATABASE IF NOT EXISTS DBNAME"); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Evangelist
    Join Date
    Feb 2000
    Location
    England
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    brilliant. thanks.


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
  •