php与postgresql数据库

i wanna to connect to postgresql database using php but it display a blank screen when submit and doesnt execute the query

Thanks in advance

Update: this is my code

function execute_query($dbName,$query){ 
  $host = "localhost"; 
  $user = "postgres"; 
  $pass = ""; 
  $db = "test"; 
  echo "before create connection"; 
  $con = pg_connect ("host=$host dbname=$db user=$user password=$pass"); 
  echo "After connection is created"; 
  if (!$con) { 
    echo "not connected"; 
//   die('Could not connect: ' . mysql_error());
  } 
  $result = pg_query($con, $query); 
  pg_close($con); 
  return $result; 
}

The output: display the message "before connection" but doesn't display the message "After connection is created" or "not connected".

Try checking your web server's error log (for instance, /var/log/apache2/error.log is a common location for the Apache2 log) and see if there is an error reported from PHP there.

You may want to set the php error reporting level in your ini file if this is a local development server.

The problem is likely a PHP error that’s getting recorded to a log file somewhere. Locate the log file, or enable showing the log errors on your page by using the following at the top of your script:

ini_set('display_errors', '1');
error_reporting(E_ALL | E_STRICT);

This is a short-term solution and can’t be used in deployment (where you want to set display_errors to 0). For a long-term solution, you really want to locate the Apache or PHP error log and tail it.

To try to find the error log, run the following script:

<?php phpinfo(); ?>

In the Configuration > PHP Core section, look for error_log. If that’s not set, you can set it in your php.ini file. All errors will be recorded to that file, even if you have display_errors set to 0.

It seems, that your php does not have postgresql support, cf. http://us.php.net/manual/en/ref.pgsql.php:

Note: Not all functions are supported by all builds. It depends on your libpq (The PostgreSQL C client library) version and how libpq is compiled. If PHP PostgreSQL extensions are missing, then it is because your libpq version does not support them.

Add a php file to your server and put this in that file:

<?php
echo phpinfo();
?>

When you open that file from the browser, check if postgres support is setup for php. you should something like this on the page:

pgsql

PostgreSQL Support  enabled
PostgreSQL(libpq) Version   8.2.3
Multibyte character support enabled
SSL support disabled
Active Persistent Links 0
Active Links    0