Re: warning message to hide

From: Date: Sat, 14 Apr 2007 17:12:40 +0000
Subject: Re: warning message to hide
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-252946@lists.php.net to get a copy of this message
On 4/14/07, siavash1979@telus.net <siavash1979@telus.net> wrote:
Quoting Alain Roger <raf.news@gmail.com>: Hi, Today i discovered that when my host webserver has some issue with PostgreSQL database, my code displays the following error message : *"Warning*: pg_connect() [function.pg-connect<http://www.immense.sk/function.pg-connect>]: Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "pgsql.exohosting.sk" and accepting TCP/IP connections on port 5432? in */www/xxxx.php* on line yyy." I would like instead of that, to display my own error message... in fact, i would like to display something like : "We are sorry but temporary we have some technical issues. Please try again later". how can i do that ? i tried to do : $conn = pg_connect($conn_string); try putting an @ sign before this line. something like this: @$conn = pg_connect($conn_string);
According to the manual: http://www.php.net/manual/en/language.operators.errorcontrol.php the @ should be placed before the function, so like this: $conn = @pg_connect($conn_string); And if you want also to generate your own error. $conn = @pg_connect($conn_string) or die("My error here!"); This will show My error here! when the function can't connect. Tijnema


« previous php.general (#252946) next »