keezel Posted August 28, 2010 Share Posted August 28, 2010 Hello all. I am terrible at PHP, but it's pretty handy and I like it far better than other languages. I'm trying to write a program to perform some pretty simple math, but it's giving me a syntax error. I am not familiar enough with PHP syntax to know why. Here is the code: <?php $variable = 14; $TaxesPaid; $OneBracket1 = 1; $OneBracket12 = 12; $OneBracket22 = 22; $OneBracket32 = 32; $OneBracket42 = 42; $OneBracket52 = 52; if($variable <= $OneBracket1): $TaxesPaid = $variable * 0.10; elseif($variable <= $OneBracket12 && >= $OneBracket1): $TaxesPaid = $variable * 0.15; elseif($variable <= $OneBracket22 && >= $OneBracket12): $TaxesPaid = $variable * 0.25; elseif($variable <= $OneBracket32 && >= $OneBracket22): $TaxesPaid = $variable * 0.28; elseif($variable <= $OneBracket42 && >= $OneBracket32): $TaxesPaid = $variable * 0.33; elseif($variable >= $OneBracket52): $TaxesPaid = $variable * 0.35; else: echo "death" echo $TaxesPaid; ?> Here is the error I'm receiving: Parse error: syntax error, unexpected T_IS_GREATER_OR_EQUAL in (local directory) on line 16 I tried writing the same snippet of code with { }'s instead of : to separate the if clauses but I'm getting the same error. It appears to be an error with the comparison operators ( >=, &&, <=). I tried switching some of these around, like =>, and received a different error. I think the latter (=>) is more for arrays than if statements. Any guidance would be extremely appreciated! I've been wrestling with this for awhile now... Quote Link to comment https://forums.phpfreaks.com/topic/211936-parse-error-unexpected-t_is_greater_or_equal/ Share on other sites More sharing options...
trq Posted August 28, 2010 Share Posted August 28, 2010 These lines make no sense.... elseif($variable <= $OneBracket12 && >= $OneBracket1): Should be..... elseif($variable <= $OneBracket12 && $variable >= $OneBracket1): Quote Link to comment https://forums.phpfreaks.com/topic/211936-parse-error-unexpected-t_is_greater_or_equal/#findComment-1104559 Share on other sites More sharing options...
keezel Posted August 28, 2010 Author Share Posted August 28, 2010 In the immortal words of Homer Simpson....d'oh! Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/211936-parse-error-unexpected-t_is_greater_or_equal/#findComment-1104563 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.