Cooper94 Posted February 10, 2009 Share Posted February 10, 2009 Is it possible say I want the system to update a table but the table dosnt exisits how would I display a error message that says such a thing? Thank You Quote Link to comment https://forums.phpfreaks.com/topic/144682-doesnt-exists/ Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 $result = mysql_query("DESC table_name") or die("Table tablename does not exist"); Would be one way. If mysql_error is called, it will return: Table 'bbname.tablename' doesn't exist Upon an invalid tablename. Quote Link to comment https://forums.phpfreaks.com/topic/144682-doesnt-exists/#findComment-759176 Share on other sites More sharing options...
The Little Guy Posted February 10, 2009 Share Posted February 10, 2009 Like this: $result = mysql_query("show tables like 'dog'"); if(mysql_num_rows($result) < 1){ echo 'Table doesn\'t exist'; }else{ echo 'Table doesn\'t exist'; } Quote Link to comment https://forums.phpfreaks.com/topic/144682-doesnt-exists/#findComment-759182 Share on other sites More sharing options...
trq Posted February 10, 2009 Share Posted February 10, 2009 Like this: $result = mysql_query("show tables like 'dog'"); if(mysql_num_rows($result) < 1){ echo 'Table doesn\'t exist'; }else{ echo 'Table doesn\'t exist'; } That'll never fly. Quote Link to comment https://forums.phpfreaks.com/topic/144682-doesnt-exists/#findComment-759208 Share on other sites More sharing options...
The Little Guy Posted February 10, 2009 Share Posted February 10, 2009 Like this: $result = mysql_query("show tables like 'dog'"); if(mysql_num_rows($result) < 1){ echo 'Table doesn\'t exist'; }else{ echo 'Table doesn\'t exist'; } That'll never fly. What do you mean? Quote Link to comment https://forums.phpfreaks.com/topic/144682-doesnt-exists/#findComment-759211 Share on other sites More sharing options...
trq Posted February 10, 2009 Share Posted February 10, 2009 Hmmm... maybe it will. Sorry Little Guy. Quote Link to comment https://forums.phpfreaks.com/topic/144682-doesnt-exists/#findComment-759213 Share on other sites More sharing options...
PFMaBiSmAd Posted February 10, 2009 Share Posted February 10, 2009 I have a question, why do you expect to be querying tables that might not exist? Do you have tables that get deleted? Once your application has been installed the tables it needs will exist and your code won't be in a position of querying a table that does not exist. Your application should know what tables it uses and if you are doing something like dynamically creating tables to hold information that is the same type you already have a table for, don't create a separate table for it, use the existing table. Quote Link to comment https://forums.phpfreaks.com/topic/144682-doesnt-exists/#findComment-759261 Share on other sites More sharing options...
The Little Guy Posted February 10, 2009 Share Posted February 10, 2009 I have a question, why do you expect to be querying tables that might not exist? Do you have tables that get deleted? Once your application has been installed the tables it needs will exist and your code won't be in a position of querying a table that does not exist. Your application should know what tables it uses and if you are doing something like dynamically creating tables to hold information that is the same type you already have a table for, don't create a separate table for it, use the existing table. Maybe he is a web host, and allows users one+ tables? Quote Link to comment https://forums.phpfreaks.com/topic/144682-doesnt-exists/#findComment-759275 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.