By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,729 Members | 1,386 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,729 IT Pros & Developers. It's quick & easy.

Testing if a mysql table exists

P: n/a
sam
Is there a simple way to test if a mysql table exists?
JUST One line !
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, 17 Oct 2003 01:02:57 +0200, "sam" <rb*****@caramail.com> wrote:
Is there a simple way to test if a mysql table exists?
JUST One line !


Depends how many commands you put on one line.

$res = mysql_query("show table status like '$tablename'")
or die(mysql_error());
$table_exists = mysql_num_rows($res) == 1;

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.