RE: [PHP-DB] R: [PHP-DB] How to prevent error on connect failure ...

From: Date: Wed, 20 Sep 2000 20:51:44 +0000
Subject: RE: [PHP-DB] R: [PHP-DB] How to prevent error on connect failure ...
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-3008@lists.php.net to get a copy of this message
You can use '@' to suppress errors like @mysql_pconnect() or you can just turn off error display in your php.ini file. Jason -----Original Message----- From: Enrico Comini [mailto:enrico@algobit.com] Sent: Wednesday, September 20, 2000 2:56 PM To: ML-PHP-DB Subject: [PHP-DB] R: [PHP-DB] How to prevent error on connect failure ... -----Messaggio originale----- Da: Andris Jancevskis [mailto:a.jancevskis@konts.lv] Inviato: mercoledi 20 settembre 2000 8.32 A: PHP-DB LIST Oggetto: [PHP-DB] How to prevent error on connect failure ... Hi, I want to prevent error message on mysql_pconnect() if connection is not established. ------------------------------------------------------------------------ I use this my system with Postgres but I think valid for all if (!$conn = pg_connect("host=$host port=$port dbname=$database user=$user")) {echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;URL=noconnect.php3?MESSAGE=NO&ret_address=".substr($REQUEST_URI, 0,strlen($REQUEST_URI)-strlen(strstr($REQUEST_URI,'?')))."&".rec_query($QUER Y_STRING,$HTTP_POST_VARS)."\">";die();} I redirect to url noconnect.php3 with many variables, the address of the page to retry and all variable received (via POST & via GET). A special variable MESSAGE is a flag for special message (es IMPORTANT ecc ecc). Noconnect.php3 -------------- <?php require("config.ini"); $que_string=strstr($QUERY_STRING,'&'); // ritorna query string meno il MESSAGGIO=... $que_string=substr($que_string,1,strlen($que_string)-1) ; // tolgo & $que_string=strstr($que_string,'&'); // ritorna query string meno il ret_address=... $que_string=substr($que_string,1,strlen($que_string)-1) ; // tolgo & // questa query string deve essere spedita cosi' com'e' in quanto gia urlencode ?> <HTML><HEAD><TITLE>CONNECTION FAILURE</TITLE> </HEAD> <BODY bgcolor="#000000"> &nbsp; <?php if ($MESSAGE=="NO") { echo " <div align=\"center\"> <center> <table border=\"0\" width=\"85%\" bgcolor=\"#000000\"> <tr> <td> <p align=\"center\"><b><font color=\"#FF0000\" size=\"6\">ALERT&nbsp;</font><font color=\"#FF0000\" size=\"5\"><br> </font><font color=\"#FF0000\" size=\"4\"> DATABASE NOT AVAILABLE</font></b></td> </tr> <tr> <td colspan=\"3\" bgcolor=\"#0000FF\" width=\"825\"> &nbsp;</td> </tr> </center> <tr> <td colspan=\"3\" width=\"819\"> <p align=\"center\"><b><a href=\"".$ret_address."?".$que_string."\"><font face=\"Arial\" size=\"5\" color=\"#FFFF00\">RETRY </font></a></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp; <b><a href=\"http://$website\"><font face=\"Arial\" size=\"5\" color=\"#FFFF00\">HOME PAGE</font></a></b></td> <center> </tr> <tr> <td colspan=\"3\" bgcolor=\"#0000FF\" width=\"825\"> &nbsp;</td> </tr> </table> </center> </div> <p align=\"center\">&nbsp; <p align=\"center\">&nbsp; <p align=\"center\">&nbsp; <p align=\"center\">&nbsp; <p align=\"center\">&nbsp; <p align=\"center\">&nbsp;</p>"; } else { echo " <div align=\"center\"> <center> <table border=\"0\" width=\"85%\" bgcolor=\"#000000\"> <tr> <td> <p align=\"center\"><b><font color=\"#FF0000\" size=\"6\">ALERT&nbsp;</font><font color=\"#FF0000\" size=\"5\"><br> </font><font color=\"#FF0000\" size=\"4\"> DATABASE NOT AVAILABLE</font></b></td> </tr> <tr> <td colspan=\"3\" bgcolor=\"#0000FF\"> <p align=\"center\"><font size=\"4\"><br> </font><font size=\"4\" color=\"#FFFF00\">VERY IMPORTANT OPERATION<br> FOR A CORRECT TRANSATION <br> ******** YOU MUST RETRY ******** </font></td> </tr> <tr> <td colspan=\"3\"> <p align=\"center\"><b><a href=\"".$ret_address."?".$que_string."\"><font face=\"Arial\" size=\"5\" color=\"#FFFF00\">RETRY</font></a></b></td> </tr> <tr> <td colspan=\"3\" bgcolor=\"#0000FF\"> <p align=\"center\"> <font size=\"4\"> <br> </font> <font size=\"4\" color=\"#FFFF00\"> SEND ME A EMAIL IF IMPOSSIBLE TO CONNECT</font></td> </tr> <tr> <td colspan=\"3\"> <p align=\"center\"><b><a href=\"MAILTO:$myemail\"><font face=\"Arial\" size=\"5\" color=\"#FFFF00\">SEND EMAIL</font> </a></b></td> </tr> </table> </center> </div> <p align=\"center\">&nbsp;</p>"; } </BODY></HTML> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net _______________________________________________________ Site Design, Hosting, and E-Commerce at www.webpipe.net

« previous php.db (#3008) next »