Dracolas Posted January 13, 2010 Share Posted January 13, 2010 http://www.sourcepod.com/sfnuul38-2501 the else in question is highlighted....why am i getting an error saying: Parse error: syntax error, unexpected T_ELSE in /home/a1237238/public_html/clan/addwar.php on line 50 I don't understand why that's wrong... Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/ Share on other sites More sharing options...
merylvingien Posted January 13, 2010 Share Posted January 13, 2010 if ($crank <= 4){ echo "<Select name='player1'>"; } $result = mysql_query("SELECT * FROM users order by rank"); while($row = mysql_fetch_assoc($result)){ $name = $row['username']; echo "<option value='$name'>$name</option>" } echo "</select>"; else{ echo('Sorry, only Corporals or above may Recruit at this time'); echo('<br><a href="console.php">Back To Console</a>'); } include("footer.php"); ?> Try that. Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-994383 Share on other sites More sharing options...
sasa Posted January 13, 2010 Share Posted January 13, 2010 you don't close while block and if block before else Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-994386 Share on other sites More sharing options...
Dracolas Posted January 13, 2010 Author Share Posted January 13, 2010 ok i re uploaded with what i did to try to fix it sasa http://www.sourcepod.com/ghbpkf84-2504 now it doesn't like the } on 49....wth is going on...lol Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-994390 Share on other sites More sharing options...
sasa Posted January 13, 2010 Share Posted January 13, 2010 add ; to the end of 48th line Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-994391 Share on other sites More sharing options...
Dracolas Posted January 13, 2010 Author Share Posted January 13, 2010 http://www.sourcepod.com/pvnsol36-2506 Before i remembered to add the <?php it gave me an empty text box with the names after it once i added the <?php it doesn't like the else again... Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-994396 Share on other sites More sharing options...
sasa Posted January 13, 2010 Share Posted January 13, 2010 if ($crank <= 4) { ?> Player 1: <Select name='player1'> <?php $result = mysql_query("SELECT * FROM users order by rank"); while($row = mysql_fetch_assoc($result)){ $name = $row['username']; echo "<option value='$name'>$name</option>"; } ?> </select> <?php } else { echo('Sorry, only Corporals or above may Recruit at this time'); echo('<br><a href="console.php">Back To Console</a>'); } include("footer.php"); Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-994397 Share on other sites More sharing options...
Dracolas Posted January 13, 2010 Author Share Posted January 13, 2010 Woot...thanks man! Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-994399 Share on other sites More sharing options...
Dracolas Posted January 13, 2010 Author Share Posted January 13, 2010 OK...i really don't get why this is happening...w/e you did to fix it...i added the other fields and now it doesn't work again...it still doesn't like that else.... http://www.sourcepod.com/xuqycn60-2509 Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-994407 Share on other sites More sharing options...
sasa Posted January 13, 2010 Share Posted January 13, 2010 remove <'php from line 38 in line 152 you have else with no if before Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-994430 Share on other sites More sharing options...
Dracolas Posted January 14, 2010 Author Share Posted January 14, 2010 there is no <?php on line 38 Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-995063 Share on other sites More sharing options...
Dracolas Posted January 15, 2010 Author Share Posted January 15, 2010 any clue guys? Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-995642 Share on other sites More sharing options...
Buddski Posted January 15, 2010 Share Posted January 15, 2010 Line 40 has a <? on it that is should'nt.. Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-995644 Share on other sites More sharing options...
Dracolas Posted January 15, 2010 Author Share Posted January 15, 2010 didn't fix...it's still not liking that else...i don't really understand why http://www.sourcepod.com/vxrzin53-2530 Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-995649 Share on other sites More sharing options...
Buddski Posted January 15, 2010 Share Posted January 15, 2010 Try this at the bottom <input type="submit" name="submit" value="Add War">; <?php } } else { echo('Sorry, only Corporals or above may Recruit at this time'); echo('<br><a href="console.php">Back To Console</a>'); } Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-995651 Share on other sites More sharing options...
Dracolas Posted January 15, 2010 Author Share Posted January 15, 2010 wow.. ty. so the problem was not closing the if...that's understandable and i'll keep an eye on that in the future Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-995661 Share on other sites More sharing options...
Buddski Posted January 15, 2010 Share Posted January 15, 2010 Also try indenting your code in the future it makes life A LOT easier when trying to find things like this... Quote Link to comment https://forums.phpfreaks.com/topic/188363-unexpected-else/#findComment-995663 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.