montgomery Posted February 17, 2008 Share Posted February 17, 2008 Once in a while when our hosting company has problems out site breaks and shows some ugly error messages: "Warning: mysql_connect(): Too many connections in ./settings.inc.php on line 90" This of course looks very unprofessional. What can I do to redirect the user to an "under maintenance" page, every time the problem occurs? Thanks a lot!! Montgomery Link to comment https://forums.phpfreaks.com/topic/91571-warning-mysql_connect-is-if-possible-to-redirect-if-error-message/ Share on other sites More sharing options...
wildteen88 Posted February 17, 2008 Share Posted February 17, 2008 What you could do is do the following when mysql_connect returns an error @mysql_connect('lcoalhost', 'username', 'passsword') or die('maintenance message here'); Link to comment https://forums.phpfreaks.com/topic/91571-warning-mysql_connect-is-if-possible-to-redirect-if-error-message/#findComment-469027 Share on other sites More sharing options...
pocobueno1388 Posted February 17, 2008 Share Posted February 17, 2008 You could do something like this: <?php if ($conn = mysql_connect("....")){ //connection made } else { //need to redirect header("Location: www.sample.php"); } ?> Link to comment https://forums.phpfreaks.com/topic/91571-warning-mysql_connect-is-if-possible-to-redirect-if-error-message/#findComment-469028 Share on other sites More sharing options...
montgomery Posted February 17, 2008 Author Share Posted February 17, 2008 I found the line 90 in settings.inc.php where the error occurs: if(!mysql_connect($DbHost,$DbUser,$DbPassword)) { $NOTCONNECTED = TRUE; } could I just change it to: if(!mysql_connect($DbHost,$DbUser,$DbPassword)) { $NOTCONNECTED = TRUE; header("Location: www.sample.php"); } Link to comment https://forums.phpfreaks.com/topic/91571-warning-mysql_connect-is-if-possible-to-redirect-if-error-message/#findComment-469054 Share on other sites More sharing options...
pocobueno1388 Posted February 17, 2008 Share Posted February 17, 2008 could I just change it to: if(!mysql_connect($DbHost,$DbUser,$DbPassword)) { $NOTCONNECTED = TRUE; header("Location: www.sample.php"); } Yes, although the variable $NOTCONNECTED will be linked somewhere else in the script, so I would check that out to see what it does. Link to comment https://forums.phpfreaks.com/topic/91571-warning-mysql_connect-is-if-possible-to-redirect-if-error-message/#findComment-469057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.