I want to retrieve data from my database 'phpopdracht5' with table 'users' and attributes 'name' (VARCHAR(20)) and 'id' (INTEGER), but it's just not working. There must be something wrong with my code
<?php
define("DB_HOST", "localhost");
define("DB_USERNAME", "root");
define("DB_PASSWORD", "");
define("DB_NAME", "phpopdracht5");
try
{
$db_conn = new PDO('mysql:host='.DB_HOST.';dbname'.DB_NAME,DB_USERNAME,DB_PASSWORD);
}
catch(PDOException $e)
{
print "Error!:".$e->getMessage()."\n";
die();
}
$sth = $db_conn->prepare('SELECT * FROM users');
$sth->bindParam(':name', $name, PDO::PARAM_STR, 20);
$sth->bindParam(':id', $id, PDO::PARAM_INT);
$sth->execute();
while ($row = $sth->fetch(PDO::FETCH_BOTH)) {
echo $row[0];
}
?>