Jump to content

Recommended Posts

I get an unexpected T_ELSE on line 42

 

<?PHP
include('Connect.php');
include('top.php');
$ID = $_COOKIE['UserID'];
if(!isset($ID))
{
echo "You must be logged in to view this page";
}
include('bottom.php');
exit;
$Result = mysql_query("SELECT * FROM users WHERE ID='$ID'") or die (mysql_error());
while($Rows = mysql_fetch_array($Result))
{
if($Rows['story_area']=="1")
{
if($Rows['gender']=="Male")
{
if(isset($_POST['submit']))
{
echo "Announcer: The Pokébowl, who'll win it tonight folks? Over here we have the Charmanders!<br />
Captain: Char, Charmander *LETS GET HIM GUYS!*<br />
Announcer: And over here we have.. The Squirtles!<br />
Captain2: SQUIRT, SQUIRTLE!! *C'MON! BRING IT ON!*<br />
Announcer2: This will be a big game! Two rivals in the final match! Go go go!<br />
58 minutes later..<br />
Announcer: This si a close one! 48-48 Tie game! The Squirtle captain ahs the ball! Hes going in for the kill! The 30, the 20, the 10, the 5! TOUCHDOWN!<br />
Announcer2: That was some game, bob!<br />
Announcer: Yes it was, Jim! 48- 54!<br />
Jimmy: That was a good game. but I think you should go home now.<br />
<form method='post'>
<input type='submit' name='home' value='Head Home'></form>";
}
else
{
echo "Jimmy: Hi, " . $Rows['username'] . "I'm heading to the Pokébowl later, wanna come? I got tickets! Front row center!<br />"
. $Rows['username'] . ": Nah. I promised I'd help my mom with some chores..<br />
Jimmy: Aw! On Pokébowl night! C'mon! You gotta come!<br />"
. $Rows['username'] . ": Hmm.. I guess my mom wouldn't mind. Okay, I'll go!<br />
<form method='post'>
<input type='submit' name='submit' value='proceed'></form>";
}
else
{
echo "Blah";
}
else
{
echo "Blah 2";
}
}
include('bottom.php')
?>

 

I just cant seem to find out why.. Help?

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

Indenting your code will make it a lot easier to find the problem.

 

Your not closing your bracket to this line

while ($Rows = mysql_fetch_array($Result)) {

 

Or this line

if ($Rows['story_area']=="1") {

 

Here is an indented version of your code

 

<?php

include('Connect.php');
include('top.php');
$ID = $_COOKIE['UserID'];
if (!isset($ID)) {
    echo "You must be logged in to view this page";
}
include('bottom.php');
exit;
$Result = mysql_query("SELECT * FROM users WHERE ID='$ID'") or die(mysql_error());
while ($Rows = mysql_fetch_array($Result)) {
    if ($Rows['story_area']=="1") {
        if ($Rows['gender']=="Male") {
            if (isset($_POST['submit'])) {
                echo "Announcer: The Pokébowl, who'll win it tonight folks? Over here we have the Charmanders!<br />
                Captain: Char, Charmander *LETS GET HIM GUYS!*<br />
                Announcer: And over here we have.. The Squirtles!<br />
                Captain2: SQUIRT, SQUIRTLE!! *C'MON! BRING IT ON!*<br />
                Announcer2: This will be a big game! Two rivals in the final match! Go go go!<br />
                58 minutes later..<br />
                Announcer: This si a close one! 48-48 Tie game! The Squirtle captain ahs the ball! Hes going in for the kill! The 30, the 20, the 10, the 5! TOUCHDOWN!<br />
                Announcer2: That was some game, bob!<br />
                Announcer: Yes it was, Jim! 48- 54!<br />
                Jimmy: That was a good game. but I think you should go home now.<br />
                <form method='post'>
                <input type='submit' name='home' value='Head Home'></form>";
            } else {
                echo "Jimmy: Hi, " . $Rows['username'] . "I'm heading to the Pokébowl later, wanna come? I got tickets! Front row center!<br />"
                . $Rows['username'] . ": Nah. I promised I'd help my mom with some chores..<br />
Jimmy: Aw! On Pokébowl night! C'mon! You gotta come!<br />"
                . $Rows['username'] . ": Hmm.. I guess my mom wouldn't mind. Okay, I'll go!<br />
                <form method='post'>
                <input type='submit' name='submit' value='proceed'></form>";
            } else {
                echo "Blah";
            } else {
                echo "Blah 2";
            }
        }

include('bottom.php')
?>

Try changing your code to this

 

<?php

include('Connect.php');
include('top.php');
$ID = $_COOKIE['UserID'];
if (!isset($ID)) {
    echo "You must be logged in to view this page";
}
include('bottom.php');
exit;
$Result = mysql_query("SELECT * FROM users WHERE ID='$ID'") or die(mysql_error());
while ($Rows = mysql_fetch_array($Result)) {
    if ($Rows['story_area']=="1") {
        if ($Rows['gender']=="Male") {
            if (isset($_POST['submit'])) {
                echo "Announcer: The Pokébowl, who'll win it tonight folks? Over here we have the Charmanders!<br />
                Captain: Char, Charmander *LETS GET HIM GUYS!*<br />
                Announcer: And over here we have.. The Squirtles!<br />
                Captain2: SQUIRT, SQUIRTLE!! *C'MON! BRING IT ON!*<br />
                Announcer2: This will be a big game! Two rivals in the final match! Go go go!<br />
                58 minutes later..<br />
                Announcer: This si a close one! 48-48 Tie game! The Squirtle captain ahs the ball! Hes going in for the kill! The 30, the 20, the 10, the 5! TOUCHDOWN!<br />
                Announcer2: That was some game, bob!<br />
                Announcer: Yes it was, Jim! 48- 54!<br />
                Jimmy: That was a good game. but I think you should go home now.<br />
                <form method='post'>
                <input type='submit' name='home' value='Head Home'></form>";
            } else {
                echo "Jimmy: Hi, " . $Rows['username'] . "I'm heading to the Pokébowl later, wanna come? I got tickets! Front row center!<br />"
                . $Rows['username'] . ": Nah. I promised I'd help my mom with some chores..<br />
Jimmy: Aw! On Pokébowl night! C'mon! You gotta come!<br />"
                . $Rows['username'] . ": Hmm.. I guess my mom wouldn't mind. Okay, I'll go!<br />
                <form method='post'>
                <input type='submit' name='submit' value='proceed'></form>";
            } else {
                echo "Blah";
            } else {
                echo "Blah 2";
            }
        }
   }
}

include('bottom.php')
?>

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.