borlandology Posted June 4, 2010 Share Posted June 4, 2010 Hi It's the code but when i browse the file it says: parse error, expecting `T_WHILE' in C:\xampp\htdocs\class\nav.php on line 78 where is my fault? ---------------------------------------------------- do { if ( $r = mysql_fetch_array( $result_right_sec ) ) { $sec_name = $r['name']; $sec_id = $r['id']; $sec_icon = $r['icon']; $right_cat = "{$right_cat}"." <tr>\n\t<td height='20' width='130' valign='middle' align='right' dir='rtl'><a href=\"".( "javascript:ajaxpage('sec.view.php?id=".$sec_id."', 'main1');" )."\"".( "><b>".$sec_name."</b></a></td>\n\t<td height='20' width='24' valign='middle' align='center'><img border='0' src='{$sec_icon}' width='16' height='16'></td>\n\t</tr>" ); $result_right_cat = mysql_query( "SELECT `id`, `name`, `sec` FROM cat WHERE sec='".$sec_id."' ORDER BY id ASC" ); do { } while ( !( $rr = mysql_fetch_array( $result_right_cat ) ) ); $cat_name = $rr['name']; $cat_id = $rr['id']; $right_cat = "{$right_cat}"." <tr>\n\t\t\t<td height='20' width='130' valign='middle' align='right' dir='rtl'><a href=\"".( "javascript:ajaxpage('cat.view.php?id=".$cat_id."', 'main1');" )."\"".( ">".$cat_name. "</a></td>\n\t\t\t<td height='20' width='24' valign='middle' align='center'><img border='0' src='images/switchon.gif' width='12' height='12'></td>\n\t\t\t</tr>" ); } while ( 1 ); } Quote Link to comment https://forums.phpfreaks.com/topic/203846-expecting-t_while/ Share on other sites More sharing options...
Alex Posted June 4, 2010 Share Posted June 4, 2010 This is what you're doing wrong: if ( $r = mysql_fetch_array( $result_right_sec ) ) { ... } while ( 1 ); Quote Link to comment https://forums.phpfreaks.com/topic/203846-expecting-t_while/#findComment-1067621 Share on other sites More sharing options...
borlandology Posted June 4, 2010 Author Share Posted June 4, 2010 This is what you're doing wrong: if ( $r = mysql_fetch_array( $result_right_sec ) ) { ... } while ( 1 ); Would u plz guide me more? how to solve it then? Quote Link to comment https://forums.phpfreaks.com/topic/203846-expecting-t_while/#findComment-1067652 Share on other sites More sharing options...
Daniel0 Posted June 4, 2010 Share Posted June 4, 2010 You need to put the while at the end of the do instead of the if. Quote Link to comment https://forums.phpfreaks.com/topic/203846-expecting-t_while/#findComment-1067655 Share on other sites More sharing options...
borlandology Posted June 4, 2010 Author Share Posted June 4, 2010 You need to put the while at the end of the do instead of the if. This is more complete: but if is not @ end it @ the begining of code !? $result_right_sec = mysql_query( "SELECT `id`, `name`, `icon` FROM sec ORDER BY id ASC" ); do { if ( $r = mysql_fetch_array( $result_right_sec ) ) { $sec_name = $r['name']; $sec_id = $r['id']; $sec_icon = $r['icon']; $right_cat = "{$right_cat}"." <tr>\n\t<td height='20' width='130' valign='middle' align='right' dir='rtl'><a href=\"".( "javascript:ajaxpage('sec.view.php?id=".$sec_id."', 'main1');" )."\"".( "><b>".$sec_name."</b></a></td>\n\t<td height='20' width='24' valign='middle' align='center'><img border='0' src='{$sec_icon}' width='16' height='16'></td>\n\t</tr>" ); $result_right_cat = mysql_query( "SELECT `id`, `name`, `sec` FROM cat WHERE sec='".$sec_id."' ORDER BY id ASC" ); do { } while ( !( $rr = mysql_fetch_array( $result_right_cat ) ) ); $cat_name = $rr['name']; $cat_id = $rr['id']; $right_cat = "{$right_cat}"." <tr>\n\t\t\t<td height='20' width='130' valign='middle' align='right' dir='rtl'><a href=\"".( "javascript:ajaxpage('cat.view.php?id=".$cat_id."', 'main1');" )."\"".( ">".$cat_name. "</a></td>\n\t\t\t<td height='20' width='24' valign='middle' align='center'><img border='0' src='images/switchon.gif' width='12' height='12'></td>\n\t\t\t</tr>" ); } while ( 1 ); } Quote Link to comment https://forums.phpfreaks.com/topic/203846-expecting-t_while/#findComment-1067674 Share on other sites More sharing options...
Alex Posted June 4, 2010 Share Posted June 4, 2010 This is what he means: $result_right_sec = mysql_query( "SELECT `id`, `name`, `icon` FROM sec ORDER BY id ASC" ); do { if ( $r = mysql_fetch_array( $result_right_sec ) ) { $sec_name = $r['name']; $sec_id = $r['id']; $sec_icon = $r['icon']; $right_cat = "{$right_cat}"." <tr>\n\t<td height='20' width='130' valign='middle' align='right' dir='rtl'><a href=\"".( "javascript:ajaxpage('sec.view.php?id=".$sec_id."', 'main1');" )."\"".( "><b>".$sec_name."</b></a></td>\n\t<td height='20' width='24' valign='middle' align='center'><img border='0' src='{$sec_icon}' width='16' height='16'></td>\n\t</tr>" ); $result_right_cat = mysql_query( "SELECT `id`, `name`, `sec` FROM cat WHERE sec='".$sec_id."' ORDER BY id ASC" ); do { } while ( !( $rr = mysql_fetch_array( $result_right_cat ) ) ); $cat_name = $rr['name']; $cat_id = $rr['id']; $right_cat = "{$right_cat}"." <tr>\n\t\t\t<td height='20' width='130' valign='middle' align='right' dir='rtl'><a href=\"".( "javascript:ajaxpage('cat.view.php?id=".$cat_id."', 'main1');" )."\"".( ">".$cat_name. "</a></td>\n\t\t\t<td height='20' width='24' valign='middle' align='center'><img border='0' src='images/switchon.gif' width='12' height='12'></td>\n\t\t\t</tr>" ); } } while ( 1 ); Quote Link to comment https://forums.phpfreaks.com/topic/203846-expecting-t_while/#findComment-1067750 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.