I’ve written the below code to return a single value from the table but it doesn’t seem to be working. Any idea why?
$pmname = $pdo->quote($_SESSION['pmname']);
$sql = "SELECT img FROM pm_user WHERE name=$pmname";
$result = $pdo->query($sql);
foreach ($result as $row)
{
echo $row["img"];
}
Why aren’t you
fetch-ing anything? Try replaceing theforeachwith:or even, if you’re sure there is but one single row:
Could well do the trick, though I haven’t tried this – yet.