Bill
84.***.***.***MySQL: connecting, selecting db, validating table(s) in 3 lines of code
As it says on the tin can, just 3 lines of code to connect to a MySQL database and validate that everything's in order, without left-over variables.PHP code:
// Fail if we can't authenticate.
@mysql_connect('localhost', $username, $password) OR die(mysql_error());
// Fail if we can't select the database.
@mysql_select_db($database) OR die(mysql_error());
// Fail if a required table doesn't exist or has crashed. You can replicate this line for any number of tables you want to validate.
@mysql_query('SELECT 1 FROM ' . $table . ' LIMIT 0') OR die(mysql_error());