jeff5656 Posted August 18, 2010 Share Posted August 18, 2010 I get this error so I was wondering if it is because I can't put a while inside a foreach? "syntax error, unexpected T_WHILE in home/g/h/t...." while($rows=mysql_fetch_array($rr)){ $pt_id = unserialize($rows['pts']); foreach ($pt_id as $indiv) { $q = "select * from indiv where id_incr = '$indiv'"; echo $q; $result = mysql_query($q) while $ptrow =mysql_fetch_array($result)){ echo $ptrow['v1']; echo "<br>"; } } } Link to comment https://forums.phpfreaks.com/topic/211111-while-inside-a-foreach/ Share on other sites More sharing options...
btherl Posted August 18, 2010 Share Posted August 18, 2010 The error is that you missed the ";" on the end of the line before the "while". So it thinks you're trying to put the "while" as part of the same command where you set $result. Link to comment https://forums.phpfreaks.com/topic/211111-while-inside-a-foreach/#findComment-1100962 Share on other sites More sharing options...
jeff5656 Posted August 18, 2010 Author Share Posted August 18, 2010 Thanks! Link to comment https://forums.phpfreaks.com/topic/211111-while-inside-a-foreach/#findComment-1100964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.