Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Our connection details.
- $host = 'xxx';
- $user = 'xxx';
- $password = 'xxx';
- $database = 'xxx';
- //An options array.
- //Set the error mode to "exceptions"
- $pdoOptions = array(
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_EMULATE_PREPARES => false
- );
- //Connect
- $pdo = new PDO("mysql:host=$host;dbname=$database", $user, $password, $pdoOptions);
- //Selecting multiple rows from a MySQL database using the PDO::query function.
- $sql = "SELECT * FROM `messeges` ORDER BY mID DESC LIMIT 15";
- foreach($pdo->query($sql, PDO::FETCH_ASSOC) as $row){
- echo $row['MYUSERNAME'] . ': ';
- echo $row['MESSEGE'] . '|';
- }
- $pdo = null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement