slarson20 Posted September 12, 2011 Share Posted September 12, 2011 why does while($random_user_TOTAL_COUNT <= 15 && $random_user_INFO = $random_user_USERS->fetch_object()){ work, but while($random_user_INFO = $random_user_USERS->fetch_object() && $random_user_TOTAL_COUNT <= 15){ doesn't. why??? Quote Link to comment Share on other sites More sharing options...
Pandemikk Posted September 12, 2011 Share Posted September 12, 2011 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 Quote Link to comment Share on other sites More sharing options...
slarson20 Posted September 12, 2011 Author Share Posted September 12, 2011 Thanks so much man!!! life saver!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.