Re: Chatter elimination

From: "Sam Sutch" <samuraiblog(at)gmail(dot)com>
To: paulf(at)quillandmouse(dot)com
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: Chatter elimination
Date: 2006-03-30 04:25:01
Message-ID: 219837f70603292025n1d7781abi3934ece7f8cf7cb5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Suppress the errors of the expression using the @ error suppression operator.

For example:

@pg_connect(/*your details*/);

Will suppress the errors for that expression. You can use it like this too

$connection = @pg_connect(/*your details*/);

You can also use this at the top of your script:

error_reporting(0); // see php.net/error_reporting

-Sam (shit, sorry, forgot to reply to all)

On 3/29/06, Paul M Foster <paulf(at)quillandmouse(dot)com> wrote:
> I have a php file called "coldstart.php" which is supposed to check if a
> database exists, and if not create it, and create the tables
> associated with it. It attempts a pg_connect() with the database name
> and other parameters. The first time it's run, this call returns false,
> because the database doesn't exist. At that point, I connect to the
> template1 database and create my target database, etc. After this, I
> redirect to a different PHP script, using the header() directive.
>
> This process works fine, insofar as it creates the database and tables.
> However, when the first pg_connect() is called with the name of the
> non-existent database, PostgreSQL/PHP dumps the following error message:
>
> Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL:
> database "webcust" does not exist in /var/www/qmsi/webcust/db.php on line 39
>
> Well and good. Except that when the script gets down to the header()
> call (after creating the database and tables), it has a problem, because
> headers have already been sent, in the form of the aforementioned error
> message. So it barfs right there.
>
> So the question is: Is it possible to shut off this "chatter" that
> PostgreSQL/PHP puts out when an error such as this occurs?
>
> --
> Paul M. Foster
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>

In response to

Browse pgsql-php by date

  From Date Subject
Next Message muralidhar sortur 2006-04-03 17:06:11 Unable to connect to PostgreSQL Server: Permission denied
Previous Message Paul M Foster 2006-03-30 04:09:29 Chatter elimination