Re: Script Hangs on - Mailing list pgsql-admin

From Grant
Subject Re: Script Hangs on
Date
Msg-id Pine.LNX.4.21.0106061516260.31520-100000@webster.conprojan.com.au
Whole thread Raw
In response to Script Hangs on  (Ariunbold Gerelt-Od <gereltod@kikakuya.com>)
List pgsql-admin
> <?php
> $port=9939;
> $host=\"210.111.1.10\";
> pg=pg_connect($port,$host);
> ?>

Hehe, don't escape the quotes around your variables.

Here's a function I use to connect to the database.

$dbhost = '210.111.1.10';
$dbuser = 'postgres';
$dbpasswd = 'meep';
$dbname = 'your_db';

function establish_db_connection() {
    global $dbhost;
    global $dbuser;
    global $dbpasswd;
    global $dbname;
    global $dbconn1;
    global $admin_email;

    $dbconn1 = @pg_connect ("host=$dbhost dbname=$dbname user=$dbuser
password=$dbpasswd");
    if (!($dbconn1)) {
        echo "<BR><CENTER>Could not establish database connection.
Administrators have been notified.</CENTER><BR>";
        // mail("$admin_email", "$group database connectivity is down.",
"The database is currently down", "From: $group@$SERVER_NAME\n");
        exit;
    }
}

> But problem is if somebody suddenly switch off
> the server(210.111.1.10), the script hangs on.
> How would my script check that host is open before connecting?

Edit /usr/local/lib/php.ini and make sure persistent connections is
turned off.

Goodluck.


pgsql-admin by date:

Previous
From: Ariunbold Gerelt-Od
Date:
Subject: Script Hangs on
Next
From: Ariunbold Gerelt-Od
Date:
Subject: Re: Script Hangs on