Hyaku_ Posted January 9, 2007 Share Posted January 9, 2007 [code]if(((time() - $user->last_activity)/60) > 20){ break; }..long peace of code..[/code]It works exactly like I want, except I'm getting:[code]Cannot break/continue 1 level[/code]is there something else as break or any other suggestions? Thanks! Link to comment https://forums.phpfreaks.com/topic/33516-something-like-break/ Share on other sites More sharing options...
marcus Posted January 9, 2007 Share Posted January 9, 2007 [code=php:0]if( ({time() - $user->last_activity)/60) > 20){break;}[/code] Link to comment https://forums.phpfreaks.com/topic/33516-something-like-break/#findComment-156852 Share on other sites More sharing options...
Hyaku_ Posted January 10, 2007 Author Share Posted January 10, 2007 parse error, unexpected '{'. Is that character sopose to do something or what? Link to comment https://forums.phpfreaks.com/topic/33516-something-like-break/#findComment-157590 Share on other sites More sharing options...
emehrkay Posted January 10, 2007 Share Posted January 10, 2007 is this if statement inside of a loop? Link to comment https://forums.phpfreaks.com/topic/33516-something-like-break/#findComment-157593 Share on other sites More sharing options...
Hyaku_ Posted January 10, 2007 Author Share Posted January 10, 2007 no, it just a regular if statement. I'm just trying to prevent Cannot break/continue 1 level error. Link to comment https://forums.phpfreaks.com/topic/33516-something-like-break/#findComment-157602 Share on other sites More sharing options...
emehrkay Posted January 10, 2007 Share Posted January 10, 2007 expalin what you are trying to do. i dont understand why you'd want to break at that point or what you expect the code to do if your statement is true Link to comment https://forums.phpfreaks.com/topic/33516-something-like-break/#findComment-157609 Share on other sites More sharing options...
Asheeown Posted January 10, 2007 Share Posted January 10, 2007 if( ({time() ^ Hmm have a look at that one...also their are three "(" but you only close two of them Link to comment https://forums.phpfreaks.com/topic/33516-something-like-break/#findComment-157613 Share on other sites More sharing options...
Hyaku_ Posted January 10, 2007 Author Share Posted January 10, 2007 [quote author=emehrkay link=topic=121699.msg501589#msg501589 date=1168458367]expalin what you are trying to do. i dont understand why you'd want to break at that point or what you expect the code to do if your statement is true[/quote]This is what I'm trying to do:header.php[code]if($timeout == TRUE){ // if account expires display this message and stop executing the rest of the code echo $timout_msg; break; }..[/code]header.php will be included in every page, if user account timeouts, the statement will be executed and I don't want the rest of the code to be executed, thats why I use break, but I get that error. So when the account is timeouted, this is what I get:[quote]Your account has been inactive for 29 minutes.Please login againFatal error: Cannot break/continue 1 level in /var/www/htdocs/include/header.php on line 19[/quote] Link to comment https://forums.phpfreaks.com/topic/33516-something-like-break/#findComment-157645 Share on other sites More sharing options...
emehrkay Posted January 10, 2007 Share Posted January 10, 2007 try exit; or end; Link to comment https://forums.phpfreaks.com/topic/33516-something-like-break/#findComment-157651 Share on other sites More sharing options...
Hyaku_ Posted January 10, 2007 Author Share Posted January 10, 2007 Thanks, that worked! Link to comment https://forums.phpfreaks.com/topic/33516-something-like-break/#findComment-157659 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.