View Full Version : while statement problem

05-19-2010, 05:16 AM
My code is as follows :


$db = new PDO("java:comp/env/jdbc/mysql");

$stmt = $db->query("SELECT name, url_name FROM categories");

while ($row=$stmt->fetch(PDO::FETCH_ASSOC)){
echo $row['name'] . " " . $row['url_name']";


I got the following error :

assignment without parentheses
inside If/While/For test statement; please make sure whether equality was
intended instead in
db.php:5: $stmt = $db->query("SELECT name, url_name FROM categories");
db.php:7: while ($row=$stmt->fetch(PDO::FETCH_ASSOC)){
db.php:8: echo $row['name'] . " " . $row['url_name']";
db.php:9: }

I guess it is a bug !

05-19-2010, 07:59 AM
This is a special Quercus feature to alert users of a potential programming mistake. A workaround is to encapsulate the assignment expression with parentheses:

while (($row=$stmt->fetch(PDO::FETCH_ASSOC))){

or to turn off STRICT mode.

However, if the workarounds are not feasible because you're using an off-the-shelf PHP application, then this Quercus feature can be considered a bug and we may want to remove it.

05-19-2010, 05:57 PM
The while statement has no problem! This is my mistake !

I accidentally put an additional " at the end of the echo statement just in front of the ;

Sorry !