wolf530 Posted March 23, 2008 Share Posted March 23, 2008 Sometimes php just confounds me. I'm obviously an amateur, so please bear with me here, but I can't figure out what the heck I'm missing -- all of the brackets seem accounted for! I'm trying to use the IPB SDK. According to the error message, the problem is on line 8 in the example code below: <?php $member = $SDK->get_info(); if($SDK->is_loggedin()); { ?> $pms = $SDK->get_num_new_pms(); if( $pms > 0 ); { ?> <a href="http://www.myserver.com/forums/index.php?act=Msg"><img id="new-messages" src="http://www.myserver.com/new-msgs.gif" alt="" border="0"></a> <?php } if( $pms == 0 ); { ?> <a href="http://www.myserver.com/forums/index.php?act=Msg"><img id="new-messages" src="http://www.myserver.com/no-msgs.gif" alt="" border="0"></a> <?php } } else { ?> <a href="http://www.myserver.com/forums/index.php?act=Login&CODE=00"><img id="new-messages" src="http://www.myserver.com/login.gif" alt="" border="0"></a> <?php } ?> Many thanks! Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/ Share on other sites More sharing options...
Nhoj Posted March 23, 2008 Share Posted March 23, 2008 if($SDK->is_loggedin()); { ?> remove the ?> you broke out of PHP then immediately attempted to follow it by more PHP.... Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/#findComment-498616 Share on other sites More sharing options...
wolf530 Posted March 23, 2008 Author Share Posted March 23, 2008 Still getting the same error. Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/#findComment-498618 Share on other sites More sharing options...
ohdang888 Posted March 23, 2008 Share Posted March 23, 2008 <?php $member = $SDK->get_info(); if($SDK->is_loggedin()); { $pms = $SDK->get_num_new_pms(); if( $pms > 0 ); { ?> <a href="http://www.myserver.com/forums/index.php?act=Msg"><img id="new-messages" src="http://www.myserver.com/new-msgs.gif" alt="" border="0"></a> <?php } if( $pms == 0 ); { ?> <a href="http://www.myserver.com/forums/index.php?act=Msg"><img id="new-messages" src="http://www.myserver.com/no-msgs.gif" alt="" border="0"></a> <?php } }else{ ?> <a href="http://www.myserver.com/forums/index.php?act=Login&CODE=00"><img id="new-messages" src="http://www.myserver.com/login.gif" alt="" border="0"></a> <?php } ?> Many thanks! try that Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/#findComment-498620 Share on other sites More sharing options...
wolf530 Posted March 23, 2008 Author Share Posted March 23, 2008 Okay, now I'm getting this: Parse error: syntax error, unexpected T_ELSE on the "php } }else{ " line Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/#findComment-498624 Share on other sites More sharing options...
ohdang888 Posted March 23, 2008 Share Posted March 23, 2008 ok i see it... change: <?php } if( $pms == 0 ); { ?> to: <?php } if( $pms == 0 ) { ?> Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/#findComment-498626 Share on other sites More sharing options...
kenrbnsn Posted March 23, 2008 Share Posted March 23, 2008 Remove the ";" after the "if" conditions. You can also stay in PHP for the whole piece of code: <?php $member = $SDK->get_info(); if($SDK->is_loggedin()) { $pms = $SDK->get_num_new_pms(); if( $pms > 0 ) echo '<a href="http://www.myserver.com/forums/index.php?act=Msg"><img id="new-messages" src="http://www.myserver.com/new-msgs.gif" alt="" border="0"></a>'; if( $pms == 0 ) echo '<a href="http://www.myserver.com/forums/index.php?act=Msg"><img id="new-messages" src="http://www.myserver.com/no-msgs.gif" alt="" border="0"></a>'; else echo '<a href="http://www.myserver.com/forums/index.php?act=Login&CODE=00"><img id="new-messages" src="http://www.myserver.com/login.gif" alt="" border="0"></a>'; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/#findComment-498627 Share on other sites More sharing options...
ohdang888 Posted March 23, 2008 Share Posted March 23, 2008 but remember the { and the } Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/#findComment-498628 Share on other sites More sharing options...
kenrbnsn Posted March 23, 2008 Share Posted March 23, 2008 You only need the last closing "}", which I forgot to put in my sample. You don't need "{ }" when "if" blocks are only one statement. Ken Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/#findComment-498631 Share on other sites More sharing options...
wolf530 Posted March 23, 2008 Author Share Posted March 23, 2008 That worked! So to clarify for my own learning: no ; after conditional statements? Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/#findComment-498632 Share on other sites More sharing options...
lordfrikk Posted March 23, 2008 Share Posted March 23, 2008 That worked! So to clarify for my own learning: no ; after conditional statements? Obviously. Quote Link to comment https://forums.phpfreaks.com/topic/97451-parse-error-syntax-error-unexpected/#findComment-498656 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.