Jump to content

Recommended Posts

Well i am getting this error and it is rather annoying. It was all working fine untill i added a certain part and now that certain part is causing the error the part i added was this:

 

if ($halftime[unify]=='Y'&&$halftime[Found_emp]=='Y'||($time_used>$halftime[u_time]+259200)) 
           {
echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>';
		echo'<tr><td class="admincellcen1">An Emporer has already been chosen, no more votes will be counted.</td></tr>';

           }

else
                      {

 

This is the rest of the section:

 

// Display Creator Election Section if conditions met
                    if ($newarray['Event']==1) {
if ($halftime[unify]=='Y'&&$halftime[Found_emp]=='Y'||($time_used>$halftime[u_time]+259200)) 
           {
echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>';
		echo'<tr><td class="admincellcen1">An Emporer has already been chosen, no more votes will be counted.</td></tr>';

           }

else
                      {

		echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>';
		echo'<tr><td class="admincellcen1">You can vote for a capable kingdom <b>in your empire</b> to represent as the Emperor for '.$newarray[empire].'</td></tr>';			
		// calculate how many ppl vote for this user
		$check_mine=mysql_query("SELECT COUNT(id) FROM users WHERE Svote= '$newarray[Knumber]'" ,$link ) or die(mysql_error());
		$vote_for_me=mysql_fetch_array($check_mine);
		echo'<tr><td class="admincellleft1">--<b class="highlight">'.$vote_for_me[0].'</b> Kingdoms have voted you for the Emperor.<br>';

		// Display current vote for creator
			if ($newarray['Svote']==0) echo'<span class="txtleft">-You have not vote for the Emperor yet.</span><br>';
			else {
				$check_creator=mysql_query("SELECT Svote FROM users WHERE username = '$current'" ,$link ) or die(mysql_error());
				$svote_no=mysql_fetch_array($check_creator);				
				$check_creator2=mysql_query("SELECT kname FROM users WHERE Knumber = '$svote_no[0]'" ,$link ) or die(mysql_error());
				$svote_name=mysql_fetch_array($check_creator2);
					// if vote for yourself then display differently
					if ($svote_name[0]!=$newarray[kname])	echo'--You have voted <b class="highlight">'.$svote_name[0].'</b> as the Emperor.<br>';
					else 	echo'--You have voted yourself as the Emperor.<br>';	
			}			
			echo"</td></tr>";						
		// user input realm number
		echo'<tr><td class="admincelltop1"><div align="center">Enter Realm Number of the kingdom you want to vote as Emperor:<input class="inputp" name="realm_no" type="text" size="4" maxlength="4">';
		echo"<br><input type='Submit' name='realmchange' value='Locate Realm'></div></td></tr>";	
		// user presses the change realm button
		if(isset($_POST[realmchange])) {
			echo'<tr><td class="admincellcen1">Realm Number: <b class="hignlight">'.$_POST[realm_no].'</b>';				
			$check_tb=mysql_query("SELECT * FROM users WHERE RealmID = '$_POST[realm_no]' AND empire = '$newarray[empire]' ORDER BY land, NW DESC" ,$link ) or die(mysql_error());
			$creator_tb=mysql_query("SELECT * FROM users WHERE RealmID = '$_POST[realm_no]' AND empire = '$newarray[empire]' ORDER BY land, NW DESC" ,$link ) or die(mysql_error());
			$check_realm=mysql_fetch_array($check_tb);
			if (!$check_realm[0]) {	//	no records returned
				echo'<p><b class="highlight2">Invalid Realm number or Empire selection</b><br>';					
			}	else {
					echo'<p><select class="inputp" name="creatormenu">';
					while($realm_details=mysql_fetch_array($creator_tb)){
						echo"<option>$realm_details[kname]</option>";
						}	    
			echo"</select>";
			echo'<br><input type="Submit" name="realmchange2" value="Vote for Emperor">';				
				}
		}
		echo"</td></tr></table>";

}	else {
			echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>';
			echo'<tr><td class="admincellcen1">Your empire is not ready for the Emperor Election at the moment.</td></tr></table>';			
		 }
             }

 

Im not sure if theres too many else' or if im missing a brace or something, any help would be appreciated

Link to comment
https://forums.phpfreaks.com/topic/54478-solved-t_else-error/
Share on other sites

Still a php noob, but it looks like you have too many else statements.  It works with

                        // user input realm number
                        echo'<tr><td class="admincelltop1"><div align="center">Enter Realm Number of the kingdom you want to vote as Emperor:<input class="inputp" name="realm_no" type="text" size="4" maxlength="4">';
                        echo"<br><input type='Submit' name='realmchange' value='Locate Realm'></div></td></tr>";
                        // user presses the change realm button
                        if(isset($_POST[realmchange])) {
                                echo'<tr><td class="admincellcen1">Realm Number: <b class="hignlight">'.$_POST[realm_no].'</b>';
                                $check_tb=mysql_query("SELECT * FROM users WHERE RealmID = '$_POST[realm_no]' AND empire = '$newarray[empire]' ORDER BY land, NW DESC" ,$link ) or die(mysql_error());
                                $creator_tb=mysql_query("SELECT * FROM users WHERE RealmID = '$_POST[realm_no]' AND empire = '$newarray[empire]' ORDER BY land, NW DESC" ,$link ) or die(mysql_error());
                                $check_realm=mysql_fetch_array($check_tb);
                                if (!$check_realm[0]) {        //        no records returned
                                        echo'<p><b class="highlight2">Invalid Realm number or Empire selection</b><br>';
                                }        else {
                                                echo'<p><select class="inputp" name="creatormenu">';
                                                }
                                                while($realm_details=mysql_fetch_array($creator_tb)){
                                                        echo"<option>$realm_details[kname]</option>";
                                                        }
                                echo"</select>";
                                echo'<br><input type="Submit" name="realmchange2" value="Vote for Emperor">';
                                        }
                        }
                        echo"</td></tr></table>";

        }        else {
                                echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>';
                                echo'<tr><td class="admincellcen1">Your empire is not ready for the Emperor Election at the moment.</td></tr></table>';
                         }

but I don't think that's what you're trying to do.

 

Link to comment
https://forums.phpfreaks.com/topic/54478-solved-t_else-error/#findComment-269518
Share on other sites

you can't have two else clauses in a row

 

it has to be

 

if ($x=1) {do stuff}

elseif ($x=2) {do something else}

THEN

else {do other stuff}

 

You can have more than one elseif, though.

If your if clauses aren't related to the same thing, just make them all if clauses

 

if ($x=1) {do that}

if ($y=15) {do this}

if ($z=45) {do something else}

Link to comment
https://forums.phpfreaks.com/topic/54478-solved-t_else-error/#findComment-269720
Share on other sites

what i am trying to do is this , if(this condition && this condition are met ||(or) this condition)

 

then display this

 

otherwise display

 

 

{

 

 

 

 

this

 

 

 

 

}

 

 

 

so im almost sure id need an else statement there...

 

 

As for posting it in parts and not whole, that is the part needed and being adjusted, my actual code is over 600 lines long and im sure you dont want it in here :P

Link to comment
https://forums.phpfreaks.com/topic/54478-solved-t_else-error/#findComment-269723
Share on other sites

// Display Creator Election Section if conditions met
                    if ($newarray['Event']==1) {
if ($halftime[unify]=='Y'&&$halftime[Found_emp]=='Y'||($time_used>$halftime[u_time]+259200)) 
           {
echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>';
		echo'<tr><td class="admincellcen1">An Emporer has already been chosen, no more votes will be counted.</td></tr>';

           }
}
else
                      {

Link to comment
https://forums.phpfreaks.com/topic/54478-solved-t_else-error/#findComment-269726
Share on other sites

it seems to me you have two else clauses in a row :)

 

else
                      {

		echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>';
		echo'<tr><td class="admincellcen1">You can vote for a capable kingdom <b>in your empire</b> to represent as the Emperor for '.$newarray[empire].'</td></tr>';			
		// calculate how many ppl vote for this user
		$check_mine=mysql_query("SELECT COUNT(id) FROM users WHERE Svote= '$newarray[Knumber]'" ,$link ) or die(mysql_error());
		$vote_for_me=mysql_fetch_array($check_mine);
		echo'<tr><td class="admincellleft1">--<b class="highlight">'.$vote_for_me[0].'</b> Kingdoms have voted you for the Emperor.<br>';

		// Display current vote for creator
			if ($newarray['Svote']==0) echo'<span class="txtleft">-You have not vote for the Emperor yet.</span><br>';
			else {

 

I just saw your error :)

 

if ($newarray['Svote']==0) echo'<span class="txtleft">-You have not vote for the Emperor yet.</span><br>';
			else {

 

hehe... You're missing the curly bracets on that if clause. And you have a typo! GASP

 

if ($newarray['Svote']==0) {echo'<span class="txtleft">-You have not voted for the Emperor yet.</span><br>';}
			else {

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/54478-solved-t_else-error/#findComment-269728
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.