-4

can anyone help me in step by step thank you so much.

function wampserver (){

    $host = "localhost";
    $port = "5432";
    $name = "IMSDB";
    $user = "postgres";
    $pass = "magahin";

    $pg = pg_connect("host=$host port=$port dbname=$name user=$user password=$pass")
    or die("Can't connect to database.");
}
Rizier123
  • 58,877
  • 16
  • 101
  • 156

3 Answers3

0

You do not have the Postgres extension installed in your PHP setup. Refer to your platforms documentation on how to install it.

Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195
  • what is the name of postgres extension i will add? please reply – SimpleError Feb 21 '15 at 10:56
  • Welcome to StackOverflow. We are more than willing to help, but you will have to put some effort into it yourself as well. What have you tried? Where do you go wrong? Have you read the documentation? Have you searched online for your issue? – Bart Friederichs Feb 21 '15 at 11:14
0

you should include file with class pg_connect in order get access to the function and connect your Db

0

Consider the first rule in the pg_hba.conf:

local all all peer

It means that for all local connections, the Unix user should be the same as the db user. Obviously this is not the case for you php code, hence the failure Peer authentication failed for user....

The second rule would let your script connect, but it's ignored because the first rule takes precedence:

local all all trust

This rule means that all local connections are allowed without requiring password and without checking any identity.

If that's OK with you, just delete the first rule, and reload the postgresql service for the change to take effect.

The other rules should not be relevant to the problem since they're related to TCP connections, and according to the error message, that's not that the method used by your script, it's trying to connect through the default Unix domain socket.