Re: Script Hangs on

From: Grant <grant(at)conprojan(dot)com(dot)au>
To: Ariunbold Gerelt-Od <gereltod(at)kikakuya(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Script Hangs on
Date: 2001-06-06 05:21:01
Message-ID: Pine.LNX.4.21.0106061516260.31520-100000@webster.conprojan.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-php

> <?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(at)$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.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2001-06-06 05:25:06 Re: Alternate database locations
Previous Message Ariunbold Gerelt-Od 2001-06-06 04:55:27 Script Hangs on

Browse pgsql-php by date

  From Date Subject
Next Message Csaba Bobak 2001-06-06 05:31:19 Re: Script Hangs on
Previous Message Ariunbold Gerelt-Od 2001-06-06 04:55:27 Script Hangs on