Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. <html>
  2. <head><basefont face="Arial"></head>
  3. <body>
  4. <?
  5. // database access parameters
  6. // alter this as per your configuration
  7. $host = "localhost";
  8. $user = "user";
  9. $pass = "password";
  10. $db = "database";
  11. // open a connection to the database server
  12. $connection = pg_connect ("host=$host dbname=$db user=$user
  13. password=$pass");
  14. if (!$connection)
  15. {
  16. die("Could not open connection to database server");
  17. }
  18. // generate and execute a query
  19. $query = "SELECT * FROM messages";
  20. $result = pg_query($connection, $query) or die("Error in
  21. query: $query.
  22. " . pg_last_error($connection));
  23. // get the number of rows in the resultset
  24. $rows = pg_num_rows($result);
  25. echo "There are currently $rows records in the database.";
  26. // close database connection
  27. pg_close($connection);
  28. ?>
  29. </body>
  30. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement