Captain09 Posted July 25, 2012 Share Posted July 25, 2012 I have defined: define("PROTECTION",43200); The error appears here: if (PROTECTION/86400) > 1 { echo ''.(PROTECTION/86400).' days'; } else if(PROTECTION/86400) = 1 { echo '1 day'; } else if(PROTECTION >= 3601 AND 86399 <= 86399){ echo ''.(PROTECTION/3600).' hours'; } else if(PROTECTION/3600) = 1 { echo '1 hour'; } else if(PROTECTION >= 1 AND 3599 <= 3599){ echo ''.(PROTECTION/3600).' hours'; } else { echo 'none'; } It doesn't recognizes the > please help Link to comment https://forums.phpfreaks.com/topic/266247-parse-error-syntax-error-unexpected/ Share on other sites More sharing options...
Pikachu2000 Posted July 25, 2012 Share Posted July 25, 2012 Look at where you've placed the parentheses in some of those conditions. Link to comment https://forums.phpfreaks.com/topic/266247-parse-error-syntax-error-unexpected/#findComment-1364364 Share on other sites More sharing options...
Captain09 Posted July 25, 2012 Author Share Posted July 25, 2012 now I set them like this: if (PROTECTION/86400 > 1 ){ echo ''.(PROTECTION/86400).' days'; } else if(PROTECTION/86400 == 1 ){ echo '1 day'; } else if(PROTECTION >= 3601 AND 86399 <= 86399){ echo ''.(PROTECTION/3600).' hours'; } else if(PROTECTION/3600 == 1 ){ echo '1 hour'; } else if(PROTECTION >= 1 AND 3599 <= 3599){ echo ''.(PROTECTION/3600).' hours'; } else { echo 'none'; } but It gives me out: 4320012 hours and not 12 hours Link to comment https://forums.phpfreaks.com/topic/266247-parse-error-syntax-error-unexpected/#findComment-1364366 Share on other sites More sharing options...
Pikachu2000 Posted July 25, 2012 Share Posted July 25, 2012 Then there's something else in your code echoing 43200. The above code (once corrected) outputs '12 hours' when I run it. Link to comment https://forums.phpfreaks.com/topic/266247-parse-error-syntax-error-unexpected/#findComment-1364371 Share on other sites More sharing options...
Captain09 Posted July 25, 2012 Author Share Posted July 25, 2012 oh you're right again thank you so much Link to comment https://forums.phpfreaks.com/topic/266247-parse-error-syntax-error-unexpected/#findComment-1364383 Share on other sites More sharing options...
Captain09 Posted July 25, 2012 Author Share Posted July 25, 2012 last question: how do round it to one decimal? Link to comment https://forums.phpfreaks.com/topic/266247-parse-error-syntax-error-unexpected/#findComment-1364389 Share on other sites More sharing options...
xyph Posted July 25, 2012 Share Posted July 25, 2012 round Please use google next time. Link to comment https://forums.phpfreaks.com/topic/266247-parse-error-syntax-error-unexpected/#findComment-1364396 Share on other sites More sharing options...
Captain09 Posted July 26, 2012 Author Share Posted July 26, 2012 I know the code but not how to integrate it Link to comment https://forums.phpfreaks.com/topic/266247-parse-error-syntax-error-unexpected/#findComment-1364413 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.