Jump to content


Photo

Please Help Me.. Whats wrong with this?


  • Please log in to reply
4 replies to this topic

#1 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 23 October 2006 - 06:32 PM

Heres my account activation form. Keep getting the same problem which looks like this:
Parse error: parse error, unexpected T_ELSE in /home/content/j/w/k/jwk811/html/membership/activate.php on line 28

Have no idea whats wrong with this.. I bolded line 28 where it says else.. what's wrong with it? Please help me I'm having so much problem with this, it's driving me crazy!
<?php

/* 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>";
	}
	[b]else[/b]
	{
		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' );
}
?>
Thank you so very much for any help!

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 23 October 2006 - 06:49 PM

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(strlen(mysql_error()) > 0)
	{
	die(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>";
	}
	else
	{
		echo "<strong>Your account has been activated!</strong> You may login below!<br />";
		
		include ( './login.php' );
	}
}

I think what you meant is to do something like this :)

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 23 October 2006 - 07:04 PM

<?php

/* 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(strlen(mysql_error()) > 0)
	{
	die(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' );
	}
}
?>
if i dont add in that die(mysql_error()); after if ( mysql_affected_rows ( $sql ) == 0 ) i get some other error that has to do with if ( mysql_affected_rows ( $sql ) == 0 ).. when i add in the die(mysql_error()); that same T_ELSE error is coming up exept now with your new code its the else closest to the end that has the problem.. thanks for trying but would you happen to know whats wrong still?

#4 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 23 October 2006 - 07:06 PM

What error are you getting for the mysql_affected_rows? You cant do what you wrote because the if cant have two blocks of curly braces.

Orio.
Think you're smarty?

(Gone until 20 to November)

#5 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 23 October 2006 - 07:12 PM

Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/content/j/w/k/jwk811/html/membership/activate.php on line 25




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users