I have this code for fetching data in pdo from my database:
<?php
$stmt = $pdo->query('SELECT `email` FROM hptenant WHERE user_id=:user_id');
while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
echo $row['email'] . "\n";
} ?>
But anytime I use it, it will blank my page, that is nothing after this code will show (HTML). However if I use this one,
<?php $stmt = $pdo->query('SELECT `email` FROM hptenant');
while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
echo $row['email'] . "\n";
} ?>
It will show me the emails in my database. Can somebody help me please?