Advertisement
cumanadigital

Conexión PHP-Postgres

Aug 3rd, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?
  2. //** http://cumanadigital.blogspot.com
  3. //** Conexión a Postgres con PHP
  4. //** ** **
  5. //variables de conexion para postgres
  6. $host = "localhost";
  7. $user = "postgres";
  8. $pass = "123456";
  9. $db = "nombre_base_de_datos";
  10. $puerto = "5432";
  11.  
  12. // conectarse a la base de datos
  13. $conn = pg_connect ("host=$host port=$puerto dbname=$db user=$user password=$pass");
  14. if (!$conn)
  15. {
  16.     die("No ha sido posible establecer la coneccion con la base de datos.".pg_last_error($conn));
  17.     exit;
  18. } else {
  19.     echo "<p><b>CONECTADO CON LA BASE DE DATOS</b></p>".pg_last_error($conn);          
  20. }
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement