Re: Script Hangs on

Поиск
Список
Период
Сортировка
От Grant
Тема Re: Script Hangs on
Дата
Msg-id Pine.LNX.4.21.0106061516260.31520-100000@webster.conprojan.com.au
обсуждение исходный текст
Ответ на Script Hangs on  (Ariunbold Gerelt-Od <gereltod@kikakuya.com>)
Список 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 по дате отправления:

Предыдущее
От: Ariunbold Gerelt-Od
Дата:
Сообщение: Script Hangs on
Следующее
От: Ariunbold Gerelt-Od
Дата:
Сообщение: Re: Script Hangs on