Jump to content

while loop confusion


slarson20

Recommended Posts

I'd assume when executing the expression the loops tries to assign the && logic operator and $random_user_TOTAL_COUNT <= 15, which of course won't work. I'd suspect you'd run into similar troubles doing something like:

 

<?php $foo = $bar AND $val = $i; ?>

 

The solution is to use parenthesis to give operator precedence.

 

<?php while(($random_user_INFO = $random_user_USERS->fetch_object()) && $random_user_TOTAL_COUNT <= 15) ?>

 

http://www.php.net/manual/en/language.operators.precedence.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.