Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = "localhost";
- $dbname = "work";
- $user = "root";
- $pass = "password";
- $charset = "UTF8MB4"; // if your db does not use CHARSET=UTF8MB4, you should probably be fixing that
- $dsn = "mysql:host={$host};dbname={$dbname};charset={$charset}";
- $options = [
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // highly recommended
- PDO::ATTR_EMULATE_PREPARES => false // ALWAYS! ALWAYS! ALWAYS!
- ];
- try {
- $pdo = new PDO( $dsn, $user, $pass, $options );
- // now $pdo is ready for use!
- } catch ( PDOException $e ) {
- // always catch PDOExceptions.
- // If there's a problem here, the error message will probably contain your DB password.
- // log the error.
- // during development, if your server is not public, you can display the message instead if you prefer.
- error_log( $e->getMessage() );
- }
- foreach($db->query('SELECT * FROM Out') as $row) {
- echo $row['id'].' '.$row['Client'].' '.$row['Number']. '<br>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement