T4VN is an online PHP Help community that provides PHP Tutorials, PHP Examples, PHP Scripts, PHP Support
    HOME  |  HOSTING COUPON  |  TEMPLATE  |  PHP SCRIPTS  |  LINK TO US  |  LINK  |  REGISTER | CONTACT
::: Member Login :::
 Username
 Password
 
Forgot your password ?
::: PHP Tutotal :::
  PHP Basic (7)
  PHP Advanced (4)
  PHP Database (2)
  Coding Step By Step (8)
  PHP and AJAX (0)
::: PHP Example :::
  Arrays (1)
  Code Highlighters (3)
  Database Functions (12)
  Date & Time (5)
  E-Mail (6)
  Forms (5)
  Guestbooks (1)
  Logging (2)
  Miscellaneous (10)
  Password Generators (3)
  Randomizers (3)
  String Manipulation (10)
  User Authentication (6)
::: Search On T4VN :::
::: T4VN Statistics :::
  PHP Scripts : 61
  PHP Example : 67
  PHP Tutorials : 21
  PHP News : 93
  Total Coupon : 36
  Other Tutorials :
  Member : 209
  Visitor Online : 1
  Today Visit: 402
  Total Visitor : 262412
  Most Online : 31
::: Sponsored Links :::

PR 4 For This Webpage
Home Today :

Check if a table exists

Author : nycd

Checks whether a table exists in the specified database. Returns true if the table does exist and false if it doesn't. Aslo returns false if the login information is incorrect and/or the database being called isn't present. If you have variables or constants set up for the your mysql login information, they can easily be integrated into this function. This eliminates the need to several arguements in the function.

PHP Example :

<?
function mysql_is_table($host$user$pass$db$tbl)
{
    
$tables = array();
    
$link = @mysql_connect($host$user$pass);
    @
mysql_select_db($db);
    
$q = @mysql_query("SHOW TABLES");
    while (
$r = @mysql_fetch_array($q)) { $tables[] = $r[0]; }
    @
mysql_free_result($q);
    @
mysql_close($link);
    if (
in_array($tbl$tables)) { return TRUE; }
    else { return 
FALSE; }
}
?>


Usage Example:

PHP Example :

<?
Function: mysql_is_table(mysql_hostmysql_usermysql_passworddatabase_nametable_name

if (
mysql_is_table('localhost''nycd''testing''reddoor''news')) { 
    print 
'Yes the news table is present'
} else { 
    print 
'Nope, the table isnt present'

?>


Other Example
SQL script import function
Data Type Converter between PHP and PostgreSQL
mssql escape string
Insert/Update/Delete functions
My Batch Query
Count Rows From 2 Tables


::: Resources :::
  Links Directory
  Programming 2 3
  Webmaster 2 3
  Web Design 2 3
  Web Hosting 2 3
  Other Links 2 3
  Asian ShowBiz News
  Teach Seo For You
::: New Templates :::




::: Other Tutorials :::
 Program Design

  Powered By T4VN.NET - Version 2.0 - CopyRight © T4VN.NET 2005-2007