egturnkey Posted March 16, 2010 Share Posted March 16, 2010 Hello friends, If we have the following $case1 = "11111"; $case2 = "2222"; $ad_one = "love"; $ad_two = "hate"; $ratio = "40"; srand ((float) microtime() * 10000000); $random = rand(1, 100); i wanna say the following manic problems if ($ad_two == $case1 || $ad_two == $case2) { echo $ad_one; } else { if ($random>= $ratio) { echo $ad_one; } else { echo $ad_two; } but it shows error (syntax error, unexpected $end) i know there is something wrong in if,else . can anyone please re-write it ! :'( Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted March 16, 2010 Share Posted March 16, 2010 Proper indenting will help you with these problems. Here is your code, poorly indented: <?php if ($ad_two == $case1 || $ad_two == $case2) { echo $ad_one; } else { if ($random>= $ratio) { echo $ad_one; } else { echo $ad_two; } ?> Here is your code, indented in some manner: <?php if ($ad_two == $case1 || $ad_two == $case2) { echo $ad_one; } else { if ($random>= $ratio) { echo $ad_one; } else { echo $ad_two; } // <- With proper indenting, we see clearly that you're missing a closing bracket ?> Fixed. <?php if ($ad_two == $case1 || $ad_two == $case2) { echo $ad_one; } else { if ($random>= $ratio) { echo $ad_one; } else { echo $ad_two; } } ?> You should invest in an IDE that highlights matching brackets. Quote Link to comment 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.