Advertisement
Guest User

Untitled

a guest
Sep 12th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. $hostname='localhost';
  3. $username='root';
  4. $password='';
  5.  
  6. try {
  7. $dbh = new PDO("mysql:host=$hostname;dbname=stickercollections",$username,$password);
  8. echo 'Connected to Database<br/>';
  9.  
  10. $sql = "SELECT * FROM stickercollections";
  11. foreach ($dbh->query($sql) as $row)
  12. {
  13. echo $row["collection_brand"] ." - ". $row["collection_year"] ."<br/>";
  14. }
  15.  
  16.  
  17. $dbh = null;
  18. }
  19. catch(PDOException $e)
  20. {
  21. echo $e->getMessage();
  22. }
  23. ?>
  24.  
  25. <?php
  26. $hostname='localhost';
  27. $username='root';
  28. $password='';
  29.  
  30. try {
  31. $dbh = new PDO("mysql:host=$hostname;dbname=stickercollections",$username,$password);
  32.  
  33. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
  34. echo 'Connected to Database<br/>';
  35.  
  36. $sql = "SELECT * FROM stickercollections";
  37. foreach ($dbh->query($sql) as $row)
  38. {
  39. echo $row["collection_brand"] ." - ". $row["collection_year"] ."<br/>";
  40. }
  41.  
  42.  
  43. $dbh = null;
  44. }
  45. catch(PDOException $e)
  46. {
  47. echo $e->getMessage();
  48. }
  49. ?>
  50.  
  51. abfrage = "SELECT * FROM port";
  52. $ergebnis = mysql_query($abfrage);
  53. $row = mysql_fetch_object($ergebnis)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement