ridgey28 Posted May 12, 2010 Share Posted May 12, 2010 Hi I am wondering how to tackle a problem and would like some advice. Basically I have a one time use registration script that sets up 3 tables in my database. Once the tables have been setup, I then want to protect the page from being executed again. I thought about deleting it from the server which is fine for me but is not user friendly to others when released. My thoughts were to write a function to check the database. If the database has already been setup then redirect the user, otherwise show the form. My only question is that how do you check to see if the table has not been setup without getting those horrible mysql error messages when the table does not exist. Currently using MYSQL 5 What way would you do it? Thanks in advance Tracy Quote Link to comment Share on other sites More sharing options...
trq Posted May 12, 2010 Share Posted May 12, 2010 My only question is that how do you check to see if the table has not been setup without getting those horrible mysql error messages when the table does not exist. You could use error suppression to hide said errors. eg Place @ before any call that might trigger an error. But deleting the file is likely your best option, you can have the script itself do this. Quote Link to comment Share on other sites More sharing options...
ignace Posted May 12, 2010 Share Posted May 12, 2010 If you know the database name you can do: SHOW TABLES [FROM database] or if you don't: SELECT count(*) FROM information_schema.tables WHERE table_name = <table-or-view-name> Credits: http://forums.mysql.com/read.php?101,33936,34067#msg-34067 http://forums.mysql.com/read.php?101,33936,34090#msg-34090 Quote Link to comment Share on other sites More sharing options...
ridgey28 Posted May 12, 2010 Author Share Posted May 12, 2010 Thanks guys. Deleting the file is probably the safest of options as the script is only used the once. It's a bonus that you can delete it with a little bit of PHP instead of doing it manually though. Quote Link to comment 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.