Guest User

Untitled

a guest
Jul 15th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. //pdo test which works
  2. include_once(dirname(__FILE__)."/SqlPdo.php");
  3. $pdo = new SqlPdo();
  4. //$res = $pdo->prepare("set names 'utf8'");
  5. $res = $pdo->prepare("select * from creation");
  6. $d= $res->execute();
  7. //var_dump($d);
  8. $objres = $res->fetch(PDO::FETCH_OBJ);
  9. echo "pdo test";
  10. echo "<br/>";
  11. var_dump($objres);
  12.  
  13.  
  14. //pdo test which doesnt work
  15. $hostname = "localhost";
  16. $username = "xxxx";
  17. $password = "xxxx";
  18.  
  19. try {
  20. $dbh = new PDO("mysql:host=$hostname;dbname=xxxx", $username, $password);
  21. echo "Connected to database"; // check for connection
  22. }
  23. catch(PDOException $e)
  24. {
  25. echo $e->getMessage();
  26. }
Add Comment
Please, Sign In to add comment