this is the first time for me to learn php and postgresql,i have some PC,one have a leagle ip,and the the name of this pc is
"XIN",the OS is redhat7.1,the following steps are:
1.use command setup as root,and choose postgresl,
2.create a database ,the name is "demo",and create table "news",and insert some values into the table;
3.create user nobody,grant the right of select to nobody for table;
4.us another pc and write a simple code of connect the DB,the code is "
<?
$conn=pg_pconnect("XIN","5432","nobody","","demo");
if($conn){
echo"?????????\n";
exit;
}
else {
echo"???\n";
}
?>

run under ie5,but now the errormessage is
"Warning: Unable to connect to PostgreSQL server: pqReadData() -- backend closed the channel unexpectedly. This probably means the backend terminated abnormally before or while processing the request. in /var/www/html/member/login.php on line 2
???

What's wrong,what shall do?

    have you edited the pg_hba.conf file in the $PGDATA directory of the postgres superuser?

    cd $PGDATA
    vi pg_hba.conf

    and make a line giving the other machine permissions to log in.

    You can test your permission to log in by running psql from the remote box and using the -h switch to change hosts to the database box.

    Also, check your postgresql logs. They may be syslogging, but it depends on setup. I run postgresql from a tar file, not RPM, because we have load issues the RPM doesn't (or didn't, haven't checked in a while) address.

      Thanks a lot ,in fact,i selected all the componets when i installed the redhat 7.1,so i install the postgres,now ,i had try to use postgres 7.1.2 ,and i got the .tar file ,but ,i don't know how to replace the old version ,because ,when i rpm the old version ,system told me ,something is used by other packets,python,php etc,so ,i don't how to change the version,can you tell me?

      i am sorry ,i am a freshman ,know fewer thing about the OS postgres and php i need help ,

        i edit the pg_hba.conf and add a line:
        host 0.0.0.0 0.0.0.0. trust

        and i start the postgresql by this command:
        postmaster -i -D /var/lib/pgsql/data

        the service started ,but the same error appeared,how can i?

          From the postgresql box itself, try this:

          psql -h 127.0.0.1

          and see if you can connect.

          Also, do a 'locate bin/postmaster' and see if you've got more than one installed, in case you've got more than one version of postgresql install. That can cause lots of problems.

            i telnet to the server,and input command as postgres
            "psql -h 127.0.0.1 demo"
            and i connected the demo,

            also ,i reinstalled the OS,so only one version on my server;

            now i met a new problem:

            the codeis <?
            $conn=pg_pconnect("","","","","demo");
            if(!$conn){
            echo"?????????\n";
            exit;
            }
            else {
            echo"???\n";
            }
            $result=pg_Exec($conn,"select * from news");
            if(!$resutl){
            echo"!!!!!!!!!\n";
            exit;
            }
            $arr=pgfetch_array($result,0);
            echo $arr[0]."<- array\n";
            echo $arr[1]."<- array\n";
            ?>

            and the output is
            ??? !!!!!!!!!

            the connect is ok?
            and the qurry is wrong?

              IF that code is a cut and paste, you have a typo:

              $result=pg_Exec($conn,"select * from news");
              if(!$resutl){

              that should be if (!$result)

                Write a Reply...