Jump to content


Photo

unexpected T_ELSE.. what does that mean?


  • Please log in to reply
6 replies to this topic

#1 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 22 October 2006 - 11:38 PM

something is wrond with the else but i dont know what im doing wrong

echo "<strong><font color='red'>Your account could not be activated, no user found by that id or password!</font></strong>";
	}
	else
	{
		echo "<strong>Your account has been activated!</strong> You may login below!<br />";

    		include ( './login.php' );
	}
}
else
{
	echo "<strong>You have already activated your account!</strong> You may login below!<br />";

    	include ( './login.php' );
}

it says in the error

Parse error: parse error, unexpected T_ELSE in /home/content/j/w/k/jwk811/html/membership/activate.php on line 28

not sure what that means..

#2 EngineeringGuy

EngineeringGuy
  • Members
  • PipPip
  • Member
  • 12 posts
  • LocationBakersfield, CA - 6 feet from Hell

Posted 22 October 2006 - 11:42 PM

Do you have an if statement?  Also, depending on the code above it, you may have too many }

#3 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 22 October 2006 - 11:44 PM

heres the entire script.. its to activate a user
<?

/* Account activation script */

// Get database connection

include ( './db.php' );

// Create variables from URL.

// first check if it's already been activated

$sql = mysql_query ( "SELECT COUNT(*) AS total FROM users WHERE userid = '" . mysql_real_escape_string ( $_REQUEST['id'] ) . "' AND password = '" . mysql_real_escape_string ( $_REQUEST['code'] ) . "' AND activated = 1" ) or die ( 'Query Error: ' . mysql_error );

$found = mysql_fetch_assoc ( $sql );

if ( $found['total'] == 0 )
{
	$sql = mysql_query ( "UPDATE users SET activated = 1 WHERE userid = '" . mysql_real_escape_string ( $_REQUEST['id'] ) . "' AND password = '" . mysql_real_escape_string ( $_REQUEST['code'] ) . "'" ) or die ( 'Query Error: ' . mysql_error );

	if ( mysql_affected_rows ( $sql ) == 0 ) 
        {
        die(mysql_error());
        }
	{
		echo "<strong><font color='red'>Your account could not be activated, no user found by that id or password!</font></strong>";
	}
	else
	{
		echo "<strong>Your account has been activated!</strong> You may login below!<br />";

    		include ( './login.php' );
	}
}
else
{
	echo "<strong>You have already activated your account!</strong> You may login below!<br />";

    	include ( './login.php' );
}

?>
i didnt write it so i wouldnt know much on why its wrong cuz im not all that great with this just yet... please let me know if you find any problems with this.. if its the if thing.. how would i set it up? thanks again

#4 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 22 October 2006 - 11:55 PM

do you know what the problem is anyone? please help me

#5 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 22 October 2006 - 11:59 PM

i'm getting this error lately too on one of my scripts, i'm pretty sure that it means you have more than 1 else { } statement in an if statement

#6 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 24 October 2006 - 05:13 AM

try
<?
/* Account activation script */
// Get database connection
include ( './db.php' );
// Create variables from URL.
// first check if it's already been activated
$sql = mysql_query ( "SELECT COUNT(*) AS total FROM users WHERE userid = '" . mysql_real_escape_string ( $_REQUEST['id'] ) . "' AND password = '" . mysql_real_escape_string ( $_REQUEST['code'] ) . "' AND activated = 1" ) or die ( 'Query Error: ' . mysql_error );
$found = mysql_fetch_assoc ( $sql );
if ( $found['total'] == 0 )
{
	$sql = mysql_query ( "UPDATE users SET activated = 1 WHERE userid = '" . mysql_real_escape_string ( $_REQUEST['id'] ) . "' AND password = '" . mysql_real_escape_string ( $_REQUEST['code'] ) . "'" ) or die ( 'Query Error: ' . mysql_error );

	if ( mysql_affected_rows ( $sql ) == 0 ) 
        {
        echo "<strong><font color='red'>Your account could not be activated, no user found by that id or password!</font></strong>";
        die(mysql_error());
        }
	else
	{
		echo "<strong>Your account has been activated!</strong> You may login below!<br />";

    		include ( './login.php' );
	}
}
else
{
	echo "<strong>You have already activated your account!</strong> You may login below!<br />";

    	include ( './login.php' );
}
?>


#7 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 24 October 2006 - 07:59 AM

The error is occuring because on line 25 you have an open curly bracket { but it's not preceeded by an else.

The code that sasa's provided should clear it up.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users