Fearpig Posted August 28, 2007 Share Posted August 28, 2007 Hi Guys, Could someone take a look at my code for me?! I've made another stupid error somewhere. while (odbc_fetch_row($result_Area)) { $Area_01=odbc_result($result_Area,"Area_01"); $Area_02=odbc_result($result_Area,"Area_02"); $Area_03=odbc_result($result_Area,"Area_03"); $Area_04=odbc_result($result_Area,"Area_04"); $Area_05=odbc_result($result_Area,"Area_05"); } $id = $Area_01; while(!empty($id)){ echo "moose<br>"; //some sample code to check the loop works! if ($id == $Area_01){$id == $Area_02} elseif ($id == $Area_02){$id == $Area_03} elseif ($id == $Area_03){$id == $Area_04} elseif ($id == $Area_04){$id == $Area_05} else {$id == $Area_05} } So for example if fields Area_01, Area_02, Area_03 are populated and Area_04 is empty, I would expect to see: moose moose moose Instead I get the following error message. Error: Parse error: parse error, unexpected '}' in D:\Intranet v3\Sales\home.php Can anyone see where I'm going wrong? Link to comment https://forums.phpfreaks.com/topic/67019-solved-error-in-code-while-loop/ Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 check your script for a extra } EDIT: also surely you mean (will also cause the problem) ($id == $Area_01){$id = $Area_02;} not ($id == $Area_01){$id == $Area_02} on every if Link to comment https://forums.phpfreaks.com/topic/67019-solved-error-in-code-while-loop/#findComment-336107 Share on other sites More sharing options...
Fearpig Posted August 28, 2007 Author Share Posted August 28, 2007 Cheers MadTechie, I obviously need to catch up on some sleep! Here's my revised and working While Loop in case anyone else was looking! while(!empty($id)){ echo "- $id<br>"; if ($id == $Area_01){$id = $Area_02;} elseif ($id == $Area_02){$id = $Area_03;} elseif ($id == $Area_03){$id = $Area_04;} elseif ($id == $Area_04){$id = $Area_05;} elseif ($id == $Area_05){$id = 'NULL';} } Link to comment https://forums.phpfreaks.com/topic/67019-solved-error-in-code-while-loop/#findComment-336112 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.