Results 1 to 3 of 3

Thread: [RESOLVED] Checking if a MySQL Table exists?

  1. #1

    Thread Starter
    Hyperactive Member ..:RUDI:..'s Avatar
    Join Date
    Aug 2005
    Location
    Yorkshire, England! c0d: Da Vinci
    Posts
    344

    Resolved [RESOLVED] Checking if a MySQL Table exists?

    Okay I have this:
    PHP Code:
    $tables mysql_list_tables($db['dbname']);
    $num_tables = @mysql_numrows($tables);
    $i 0;
    $exist 0;
    while(
    $i $num_tables)
    {
        
    $tablename mysql_tablename($tables$i);
    }
    if (
    $tablename=='ForumConfig') {
    $exist=1;
    $i++;
    }
    if (
    $exist==0)
    {
    die (
    "Please check your database connection and/or install MageBB.");

    However it just times out...

    Basically it's checking if a table exists, and if not, it will "die". Does anybody know a different way?? Or is the code just wrong?

    Rudi



    My Personal Home | MageBB Home | Elders Online
    Yes, Noteme is my father.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Checking if a MySQL Table exists?

    Do a mysql_query() method (or die()) with the SQL:

    SHOW TABLES LIKE 'mytablename'

  3. #3

    Thread Starter
    Hyperactive Member ..:RUDI:..'s Avatar
    Join Date
    Aug 2005
    Location
    Yorkshire, England! c0d: Da Vinci
    Posts
    344

    Re: Checking if a MySQL Table exists?

    Thanks



    My Personal Home | MageBB Home | Elders Online
    Yes, Noteme is my father.

Posting Permissions

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



Click Here to Expand Forum to Full Width