Guest User

radiogeek86

a guest
Aug 26th, 2011
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2. /*** mysql hostname ***/
  3. $hostname = 'localhost';
  4.  
  5. /*** mysql username ***/
  6. $username = 'root';
  7.  
  8. /*** mysql password ***/
  9. $password = 'MYPASS';
  10.  
  11. try {
  12. $dbh = new PDO("mysql:host=$hostname;dbname=radio1test", $username, $password);
  13. /*** echo a message saying we have connected ***/
  14.  
  15. /*** The SQL SELECT statement ***/
  16. $sql = "SELECT * FROM animals";
  17. foreach ($dbh->query($sql) as $row)
  18. {
  19. echo $row['presenter'] .' - '. $row['show'] . '<br />';
  20. }
  21.  
  22. /*** close the database connection ***/
  23. $dbh = null;
  24. }
  25. catch(PDOException $e)
  26. {
  27. echo $e->getMessage();
  28. }
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment