Advertisement
Guest User

Untitled

a guest
Jan 25th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <?php
  2. $host = "localhost";
  3. $dbname = "work";
  4. $user = "root";
  5. $pass = "password";
  6. $charset = "UTF8MB4"; // if your db does not use CHARSET=UTF8MB4, you should probably be fixing that
  7. $dsn = "mysql:host={$host};dbname={$dbname};charset={$charset}";
  8. $options = [
  9.   PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // highly recommended
  10.   PDO::ATTR_EMULATE_PREPARES => false // ALWAYS! ALWAYS! ALWAYS!
  11. ];
  12. try {
  13.   $pdo = new PDO( $dsn, $user, $pass, $options );
  14.  
  15.   // now $pdo is ready for use!
  16.  
  17. } catch ( PDOException $e ) {
  18.   // always catch PDOExceptions.
  19.   // If there's a problem here, the error message will probably contain your DB password.
  20.  
  21.   // log the error.
  22.   // during development, if your server is not public, you can display the message instead if you prefer.
  23.   error_log( $e->getMessage() );
  24. }
  25. foreach($db->query('SELECT * FROM Out') as $row) {
  26.     echo $row['id'].' '.$row['Client'].' '.$row['Number']. '<br>';
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement