Advertisement
Guest User

Untitled

a guest
Jun 15th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1.  
  2. <?php
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6.  
  7. try {
  8. $conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);
  9. // set the PDO error mode to exception
  10. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  11. $sql = "select * from ";
  12. // use exec() because no results are returned
  13. $conn->exec($sql);
  14. echo "Database created successfully<br>";
  15. }
  16. catch(PDOException $e)
  17. {
  18. echo $sql . "<br>" . $e->getMessage();
  19. }
  20.  
  21. $conn = null;
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement