Advertisement
Guest User

Untitled

a guest
Jun 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2. const HOST = 'localhost';
  3. const USER = 'abh';
  4. const PASS = '123';
  5. const DB = 'abc';
  6.  
  7. try
  8. {
  9. $conn = new PDO("mysql:host = ".HOST.";dbname = ".DB."", USER, PASS);
  10. if($conn)
  11. {
  12. echo "success";
  13. }
  14. else
  15. {
  16. echo "error";
  17. }
  18. $query = "select uid from users";
  19. $result = $conn->query($query);
  20. if(!$result)
  21. {
  22. print_r($conn->errorInfo());
  23. }
  24. else
  25. {
  26. foreach($result as $row)
  27. {
  28. echo $row['uid'];
  29. }
  30. }
  31. //$conn = null;
  32. }
  33. catch(PDOException $e)
  34. {
  35. echo $e->getMessage();
  36. }
  37. 1,5
  38. ?>
  39.  
  40. //i am getting following error
  41.  
  42. /*successArray
  43. (
  44. [0] => 3D000
  45. [1] => 1046
  46. [2] => No database selected
  47. )
  48. */ //please tell me how to fix it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement