Jump to content

Checking for Existing Tables


watagal

Recommended Posts

Greetings,I just got my PHP script working to add a new table through mysql_query("CREATE TABLE ..."). Now I would like to add a PHP check to see if the table already exists. Can someone point me in the right direction?Thanks, WG

Link to comment
Share on other sites

Just do I query to select from the database before hand with the name of the table your looking for. Then also do an if statement to see if its valid.The code:$result = mysql_query("SELECT * FROM <database>");if (!$result) {echo "Table doesn't exist";}else {echo "Table Exists already";}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...