markeh Posted July 11, 2009 Share Posted July 11, 2009 Hi, in Zend Studio I'm using this: while ($row = mysql_fetch_array($sql)) { // .. long code here } Where is something wrong with it, well it gives me a warning. When I change it to: $row = mysql_fetch_array($sql) while ($row) { // .. long code here } Would the above work? Thanks, Mark Link to comment https://forums.phpfreaks.com/topic/165579-php-while-question/ Share on other sites More sharing options...
Q695 Posted July 11, 2009 Share Posted July 11, 2009 It could, but I always use option A, and on a rare logical occasion I will nest a fetch statement. Do simple trial, and error. Link to comment https://forums.phpfreaks.com/topic/165579-php-while-question/#findComment-873380 Share on other sites More sharing options...
markeh Posted July 11, 2009 Author Share Posted July 11, 2009 No, it did not work. How can I fix this warning: Description Resource Path Location Type bool-assign : Assignment in condition login.php game line 40 Code Analyzer Error $teller = 1; $row = mysql_fetch_array($sql); while ($row = mysql_fetch_array($sql)) { if ($row['badge'] == $user['badge']) { $badge_selected = $teller; } session_badges[$teller] = $row['badge']; $teller++; } Any ideas? Link to comment https://forums.phpfreaks.com/topic/165579-php-while-question/#findComment-873383 Share on other sites More sharing options...
Q695 Posted July 11, 2009 Share Posted July 11, 2009 Do you want to use "SELECT * FROM employees WHERE badge=$badge_selected"? Link to comment https://forums.phpfreaks.com/topic/165579-php-while-question/#findComment-873385 Share on other sites More sharing options...
markeh Posted July 11, 2009 Author Share Posted July 11, 2009 $sql = mysql_query("SELECT badge FROM badges WHERE owner = '".$username."';"); Link to comment https://forums.phpfreaks.com/topic/165579-php-while-question/#findComment-873393 Share on other sites More sharing options...
trq Posted July 11, 2009 Share Posted July 11, 2009 To me, that looks like a bug in Zend studio. Its basically saying that you are creating an assignment within a condition, which you need to do in order to loop through your results ($sql). Link to comment https://forums.phpfreaks.com/topic/165579-php-while-question/#findComment-873402 Share on other sites More sharing options...
markeh Posted July 11, 2009 Author Share Posted July 11, 2009 To me, that looks like a bug in Zend studio. Its basically saying that you are creating an assignment within a condition, which you need to do in order to loop through your results ($sql). I have no knowledge of what that means... Anything else you can suggest? Is there a way I can ignore these warnings? There really annoying because I have about 160 of them in my code. Link to comment https://forums.phpfreaks.com/topic/165579-php-while-question/#findComment-873408 Share on other sites More sharing options...
trq Posted July 11, 2009 Share Posted July 11, 2009 Why not ask on a zend studio board? The issue is nothing at all to do with php. Link to comment https://forums.phpfreaks.com/topic/165579-php-while-question/#findComment-873409 Share on other sites More sharing options...
haku Posted July 11, 2009 Share Posted July 11, 2009 Have you actually run mysql_query() on your query? Link to comment https://forums.phpfreaks.com/topic/165579-php-while-question/#findComment-873445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.