Guest User

Untitled

a guest
Dec 28th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. <?php
  2. $host = 'localhost';
  3. $db_name = 'my_db';
  4. $user = 'root';
  5. $pass = '';
  6. try {
  7. $pdo = new PDO("mysql:host={$host};dbname={$db_name}", $user, $pass);
  8. } catch (PDOException $exp) {
  9. echo "PDOException:". $exp->getMessage();
  10. die();
  11. }
  12. $select = $pdo->prepare("SELECT * FROM table;");
  13. $select->execute();
  14. $result = $select->fetchAll();
  15. print_r($result);
  16. ?>
Add Comment
Please, Sign In to add comment