<?php
/*** mysql hostname ***/
$hostname = 'localhost';
/*** mysql username ***/
$username = 'root';
/*** mysql password ***/
$password = '1w3s';
try {
$dbh = new PDO("mysql:host=$hostname;dbname=asterisk", $username, $password);
/*** echo a message saying we have connected ***/
echo 'Connected to database<br />';
/*** The SQL SELECT statement ***/
$sql = "SELECT * FROM users";
foreach ($dbh->query($sql) as $row)
{
print $row['username'] .' - '. $row['password'] . '<br />';
}
/*** close the database connection ***/
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
No hay comentarios:
Publicar un comentario