In my web application, users can download a .tar.gz archive containing the app files. However, because the MySQL database won’t have been configured then, the user needs to run the install script located in ./install.
I “catch” the user upon first run of the app by checking to see if the ./install directory exists. If so, the index.php page redirects the user to the install script.
However, I was wondering if there were a more elegant way to “catch” a user upon first-run of a program.
Someone on IRC suggested the web-server create a file .installed upon completion, but because the web server might not have write privileges to the web root directory, I can’t rely on that.
How would you go about solving this problem, or is my solution workable?
When MySQL queries fail with the error code
1146, it means the tables don’t exist. You could be on the lookout for such errors, since they either mean the software wasn’t installed, or that the installation is broken.As Julian H. Lam said in the comments, the
mysql_errno()function returns that error number. In case of MySQLi, it’s either the property$connection->errnoor the function callmysqli_errno($link).