R: [PHP-DB] How to prevent error on connect failure ...
| From: | Enrico Comini | Date: | Wed, 20 Sep 2000 20:55:47 +0000 |
| Subject: | R: [PHP-DB] How to prevent error on connect failure ... | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-3005@lists.php.net to get a copy of this message | ||
-----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">
<?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 </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\">
</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;  
;
<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\">
</td>
</tr>
</table>
</center>
</div>
<p align=\"center\">
<p align=\"center\">
<p align=\"center\">
<p align=\"center\">
<p align=\"center\">
<p align=\"center\"> </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 </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\"> </p>";
}
</BODY></HTML>