Invalid argument supplied for foreach() and MySQL date formating?

Well, I don’t know what’s wrong with my code, but when I use this query:

$query = $dbh->query("SELECT name, surname, email, gg, gender, avatar, birthday, regdate, lastseen, activated FROM random WHERE id='$id'"); 

foreach($query as $row) { 
(...)
}

Everything’s is perfect.

But when I try to change date output - I’m getting the title error (the only change here is DAYNAME(‘regdate’) instead of regdate):

<?
$query = $dbh->query("SELECT name, surname, email, gg, gender, avatar, birthday, DAYNAME('regdate'), lastseen, activated FROM random WHERE id='$id'"); 

foreach($query as $row) { 
(...)
}
?>

Warning: Invalid argument supplied for foreach() in (…) on line (…)

What’s wrong? DAYNAME is just an easy example, I’m trying to convert YYYY-MM-DDD to DD.MM.YYYY in fact (DATE_FORMAT) but it doesn’t work also.

(Yes, I’m using PDO)

Thanks!

You shouldn’t quote the fieldname, as MySQL then regards it a string instead of a fieldname. I.e., try DAYNAME(regdate) instead of DAYNAME(‘regdate’)