home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / db_table_exists.lib.php < prev    next >
Encoding:
PHP Script  |  2003-11-26  |  1.4 KB  |  38 lines

  1. <?php
  2. /* $Id: db_table_exists.lib.php,v 2.2 2003/11/26 22:52:23 rabus Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5.  
  6. /**
  7.  * Ensure the database and the table exist (else move to the "parent" script)
  8.  * and display headers
  9.  */
  10. if (!isset($is_db) || !$is_db) {
  11.     // Not a valid db name -> back to the welcome page
  12.     if (!empty($db)) {
  13.         $is_db = @PMA_mysql_select_db($db);
  14.     }
  15.     if (empty($db) || !$is_db) {
  16.         if (!isset($is_transformation_wrapper)) {
  17.             header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
  18.         }
  19.         exit;
  20.     }
  21. } // end if (ensures db exists)
  22. if (!isset($is_table) || !$is_table) {
  23.     // Not a valid table name -> back to the db_details.php
  24.     if (!empty($table)) {
  25.         $is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
  26.     }
  27.     if (empty($table)
  28.         || !($is_table && @mysql_numrows($is_table))) {
  29.         if (!isset($is_transformation_wrapper)) {
  30.             header('Location: ' . $cfg['PmaAbsoluteUri'] . 'db_details.php?' . PMA_generate_common_url($db, '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
  31.         }
  32.         exit;
  33.     } else if (isset($is_table)) {
  34.         mysql_free_result($is_table);
  35.     }
  36. } // end if (ensures table exists)
  37. ?>
  38.