Advertisement
Guest User

Untitled

a guest
Jun 25th, 2014
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. <?php
  2. ini_set ("display_errors", "1");
  3.  
  4. error_reporting(E_ALL);
  5. $con="host=127.0.0.1 port=5432 dbname=website_db user=cake password=cake";
  6. $db=pg_connect($con) or die('connection failed');
  7. echo '<p>Connected to: ', pg_dbname($db).'</p>';
  8.  
  9. $result = pg_query($db, "SELECT id, name FROM public.roles");
  10. if (!$result) {
  11.   echo "<p>An error occurred: ".pg_last_error()."</p>.\n";
  12.   exit;
  13. }
  14.  
  15. while ($row = pg_fetch_row($result)) {
  16.   echo "ID: $row[0]  Name: $row[1]";
  17.   echo "<br />\n";
  18. }
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement