postgresSQL Server Connection Test Script PDF Print E-mail

This script tests a database connection to a postgreSQL Database using the postgreSQL PHP extension.

  • Save this script as postgreSQL.php in your root folder of your Joomla installation.
  • Modify username / passowrd etc in the script
  • Open a web browser and load the script, e.g. http://yoursite/postgreSQL.php

If you get a green OK echoed back then the connection was successful. If not, please stude the error messages and try to figure out what is the problem.

  1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 

 21 
 22 
 23 
 24 
 25 
 26 
 27 
 28 
 29 

 30 

 31 
 32 
 33 
 34 
<?php

///////////////////////////////////////////////////
// Joomla-R-Us
//
// Connection test to external postgreSQL Database 
// using postgreSQL PHP extension
///////////// Configure this ///////////////////// 

// Configure this
$hostname     'localhost';
$port        5432;
$database    'postgres';
$username     'postgres';
$password     'mypassword';

///////////// End Configure ///////////////////// 

if ( function_exists('pg_connect') ) {
    
$connectStr =     "host=" $hostname ." port=" $port " dbname=" 
      $database 

            
" user=" $username " password=" $password;
    
$dbconn pg_connect($connectStr);
    if ( 
$dbconn ) {
        echo 
'<b><font color="green">OK!</font></b>';
    } else {
        echo 
'<b><font color="red">CONNECTION FAILED</font></b>';
    }
} else {
    echo     
'ERROR : Could not locate pg_connect() function. Please make sure '
      .
        
'<a href="http://us2.php.net/manual/en/book.pgsql.php">postgresSQL</a> '
          .
        
'is installed and enabled in PHP.';
}

?>

Comments (0)add comment

Write comment
You must be logged in to post a comment. Please register if you do not have an account yet.

busy
 
 
  Design by augs-burg.de & go-vista.de  
 
     
 
   
 

The Joomla!(R) name is used under a limited license from Open Source Matters in the United States and other countries. http://Joomla-R-Us.com is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.