Cory94bailly Posted May 12, 2008 Share Posted May 12, 2008 Well I am making an install.php for if I ever make a script worth giving out... So far, I have the basic mysql stuff where the site admin puts in their mysql details and the info is processed... But if the admin enters something wrong, you will get the usual mysql errors.. So, I want to know how to make it say my own errors... Like maybe red text saying "That DB doesn't exist!" Any help will help (besides google....) Thanks! Quote Link to comment Share on other sites More sharing options...
andrewgarn Posted May 12, 2008 Share Posted May 12, 2008 This should work. When you execute your queries: $var = mysql_query($sql) or die("The query could not be executed"); So you put some text in the brackets following "or die" and it should display that text instead of the standard mysql_error() Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 12, 2008 Author Share Posted May 12, 2008 This should work. When you execute your queries: $var = mysql_query($sql) or die("The query could not be executed"); So you put some text in the brackets following "or die" and it should display that text instead of the standard mysql_error() How can I customize it for each error? Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 12, 2008 Author Share Posted May 12, 2008 How can I customize it for each error? *BUMP* Quote Link to comment Share on other sites More sharing options...
Skittalz Posted May 12, 2008 Share Posted May 12, 2008 change the die message? Quote Link to comment Share on other sites More sharing options...
dezkit Posted May 12, 2008 Share Posted May 12, 2008 post the code plz Quote Link to comment Share on other sites More sharing options...
revraz Posted May 12, 2008 Share Posted May 12, 2008 Define what "each error" means. You run a connect routine which either connects or it doesn't. You run a db select routine which either connects or doesn't. Then you execute sql commands which either are commited or they are not. Not too many specifics there to customize. Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 12, 2008 Author Share Posted May 12, 2008 Well like this: Invalid MySql Path: Sorry, that Mysql path is Invalid! Invalid MySql Database: Sorry, that Mysql database is Invalid! Invalid MySql Username: Sorry, that Mysql username is Invalid! Invalid MySql Password: Sorry, that Mysql password is Invalid! And I want it only so if they get 1 or 2 wrong, it will only show those 1 or 2.. Not them all! change the die message? Obviously =/ post the code please Code..? Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 12, 2008 Author Share Posted May 12, 2008 Bump =/ Quote Link to comment Share on other sites More sharing options...
peranha Posted May 13, 2008 Share Posted May 13, 2008 mysql_select_db($db) or die ("Sorry, that Mysql database is Invalid!"); Just like that, change the DIE message to whatever you want it to be. Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 13, 2008 Author Share Posted May 13, 2008 mysql_select_db($db) or die ("Sorry, that Mysql database is Invalid!"); Just like that, change the DIE message to whatever you want it to be. Ok I get that much but how would I do it if I had the code like this: mysql_connect("$sqlpath", "$sqluser", "$sqlpass") or die(mysql_error()); mysql_select_db("$sqldb") or die(mysql_error()); How would I make an error only come up for each wrong field? Like say they got the path and DB wrong, I don't want it saying "Sorry, that password is incorrect!"... 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.