Page 1 of 1

unexpected end please help

Posted: Thu Jan 20, 2005 10:17 pm
by deadshot270
this is part of a account management page

the error i get is

Code: Select all

Parse error: syntax error, unexpected $end in C:\sites\dss_php_site\modules\your_account\index.php on 
line 342
heres where i think the error is, the last line is line 339 and the rest of the code is closing up php, body, and html tags

Code: Select all

switch ( $op ) {
	case "login":
		login();
		break;
	case "logout":
		logout();
		break;
	case "registration_form":
		registration_form();
		break;
	case "registration_submit":
		registration_submit();
		break;
	case "change_user_pass":
		change_user_pass();
		break;
	case "change_info":
		change_info();
		break;
	case "update_user_pass":
		update_user_pass();
		break;
	case "update_info":
		update_info();
		break;
	default:
		manage();
}
Copyright 2004 DSS-Battalion

thanks, if u think the error is elsewhere in the script tell me and ill put the whole scrip on here

Posted: Thu Jan 20, 2005 10:25 pm
by feyd
time to post the rest of the script! :lol:

Posted: Thu Jan 20, 2005 10:27 pm
by deadshot270
here it is if u dare

Code: Select all

<?php
if (eregi("index.php",$_SERVER&#1111;'PHP_SELF'])) &#123;
    Header("Location: modules.php");
    die();
&#125;
?>
<html>
<head>
<title>DeadShotSnipers Battalion</title>
</head>
<body>
<?php
function login() &#123;
	$sql_1 = "SELECT user, pass FROM members WHERE user=md5($_POST&#1111;user]) and pass=md5($_POST&#1111;pass])";
	$sql_2 = "mysql_query(".$sql_1.")";
	if (mysql_num_rows($sql_login_2) == 1) &#123;
		session_start();
		$_SESSION&#1111;user] = $_POST&#1111;user];
		$_SESSION&#1111;pass] = md5($_POST&#1111;pass]);
		$_SESSION&#1111;logged] = "logged";
		echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php?module=your_account&op=manage"></head><body>";
		echo "Thank you for logging in. You are being redirected to Your_Account page.";
	&#125; else &#123;
		echo "The Username and Password you have enter do not match.";
	&#125;
&#125;

function logout() &#123;
	session_destroy();
	echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php"></head><body>";
&#125;

function register_form() &#123;
	?>
	<form action="modules.php?module=your_account&op=register" method="POST">
		Username:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" maxlength="20" name="user">
		<br><br>
		Password:&nbsp;&nbsp;&nbsp;&nbsp;<input type="password" name="new_pass">
		<br><br>
		Confirm
		<br>
		Password:&nbsp;&nbsp;&nbsp;&nbsp;<input type="password" name="conf_new_pass">
		<br><br>
		Registration Code
		<br>
		(given to you by an officer):&nbsp;&nbsp;&nbsp;&nbsp;<input type="password" name="registration_code">
		<br><br>
		Name:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="name">
		<br><br>
		Age:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="age" maxlength="3">
		<br><br>
		Email:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="email">
		<br><br>
		Games:&nbsp;&nbsp;&nbsp;&nbsp;
		<select type="menu" name="games" multiple>
	 		<option value="America's Army">America's Army</option>
	 		<option value="Medal fo Honor: Allied Assault">Medal fo Honor: Allied Assault</option>
	 	</select>
		<br><br>
		Internet
		<br>
		Connection:&nbsp;&nbsp;&nbsp;&nbsp;
		<select type="pulldown" name="inet_conn">
	 		<option value="DIALUP">DIAL-UP</option>
	 		<option value="DSL">DSL</option>
	 		<option value="CABLE">CABLE</option>
	 		<option value="T1">T1</option>
	 		<option value="T3">T3</option>
		</select>
		<br><br>
		Favorite
		<br>
		Maps:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<select type="menu" name="maps" multiple>
			<option value="bridge_crossing">Bridge Crossing</option>
			<option value="hq_raid">Headquarters Raid</option>
			<option value="mout_mckenna">MOUT McKenna</option>
			<option value="collapsed_tunnel">Collapsed Tunnel</option>
			<option value="pipeline">Pipeline</option>
			<option value="insurgent_camp">Insurgent Camp</option>
			<option value="fls_assault">FLS Assault</option>
			<option value="mountain_pass">Mountain Pass</option>
			<option value="mountain_ambush">Mountain Ambush</option>
			<option value="swamp_raid">Swamp Raid</option>
			<option value="jrtc_farm_raid">JRTC Farm Raid</option>
			<option value="weapons_cache">Weapons Cache</option>
			<option value="river_basin">River Basin</option>
			<option value="weapons_cache_se">Weapons Cache SE</option>
			<option value="radio_tower">Radio Tower</option>
			<option value="bridge_se">Bridge SE</option>
			<option value="mountain_pass_se">Mountain Pass SE</option>
			<option value="pipeline_sf">Pipeline SF</option>
			<option value="sf_csar">SF CSAR</option>
			<option value="sf_recon">SF Recon</option>
			<option value="sf_hospital">SF Hospital</option>
			<option value="sf_sandstorm">SF SandStorm</option>
			<option value="sf_arctic">SF Arctic</option>
			<option value="sf_village">SF Village</option>
		</select>
		<br><br>
		Favorite
		<br>
		Weapons:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<select type="menu" size="8" name="_GUNS" multiple>
			<option value="m16a2">M16A2</option>
			<option value="m249">M249 "SAW"</option>
			<option value="m203">M203</option>
			<option value="m4a1">M4A1</option>
			<option value="sf_m4">SOPMOD M4 "SF"</option>
			<option value="m24">M24</option>
			<option value="m82">M82 "Barret"</option>
			<option value="spr">Special Forces Rifle "SPR"</option>
		</select>
		<br><br>
		Please tell us of any special skills on the computer or otherwise that you have that you could contribute to help us.:
		<br>
		<textarea name="skills" cols="50" rows="8"></textarea>
		<br><br>
		<input type="submit" name="submit" value="SUBMIT">
	</form>
	<?php
&#125;

function register_submit() &#123;
	if ($_POST&#1111;registration_code] == $registration_password) &#123;
		if ($_POST&#1111;pass] == $_POST&#1111;conf_pass]) &#123;
			$sql1 = "INSERT INTO members (user, password, name, age, email, inet_conn, maps, weapons, skills) values ($_POST&#1111;user], md5($_POST&#1111;pass]), $_POST&#1111;name],$_POST&#1111;age], $_POST&#1111;email], $_POST&#1111;inet_con], $_POST&#1111;maps], $_POST&#1111;weapons], $_POST&#1111;skills])";
			mysql_query($sql1);
			echo "Thank you for electing to become a member of the DeadShotSnipers Battalion. Our recruiting administrator will be contacting you within a few days.\n\nYour are being redirected back to our home page.";
			echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php"></head><body>";
		&#125; else &#123;
			echo "The password you entered do not match.";
			echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php?module=your_account&op=chage_user_pass"></head><body>";
		&#125;
	&#125; else &#123;
		echo "The registration code you have entered is invalid.\n\nYou are being redirected back to the registration page.";
		echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php?module=your_account&op=registration"></head><body>";
	&#125;

function manage() &#123;
	if ($_SESSION&#1111;logged] == "logged") &#123;
		?>
		<a href="modules.php?module=your_account&op=change_user_pass" target="_self">Change your Username and Password.</a>
		<br>
		<a href="modules.php?module=your_account&op=change_email" target="_self">Change your email address.</a>
		<br>
		<a href="modules.php?module=your_account&op=change_info" target="_self">Change your user information here.</a>
		<?php
	&#125; else &#123;
		echo "You must login before you can manage your account.";
		include("blocks/login_block.php");
	&#125;
&#125;

function change_user_pass() &#123;
	if ($_SESSION&#1111;logged] == "logged") &#123;
	    $sql_1 = "SELECT user FROM members WHERE user=$_SESSION&#1111;user]";
	    $sql_2 = mysql_result($sql_1); ?>
		<form action="modules.php?module=your_account&op=update_user_pass" method="POST">
		Username:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo "<input type="text" maxlength="20" name="user" value="$sql_2">"; ?>
		<br><br>
		Old Password:&nbsp;&nbsp;&nbsp;&nbsp;<input type="password" name="old_pass">
		<br><br>
		New Password:&nbsp;&nbsp;&nbsp;&nbsp;<input type="password" name="new_pass">
		<br><br>
		Confirm New
		<br>
		Password:&nbsp;&nbsp;&nbsp;&nbsp;<input type="password" name="conf_new_pass">
		<br><br>
		<input type="submit" name="submit" value="SUBMIT">
		<?php
	&#125; else &#123;
		echo "You must login before you can manage your account.";
		include("blocks/login_block.php");
	&#125;	
&#125;

function change_info() &#123;
	if ($_SESSION&#1111;logged] =="logged") &#123;
		$sql_1 = "SELECT * FROM members WHERE user=$_SESSION&#1111;user]";
		$sql_2 = mysql_fetch_array($sql_1);
		$email = $sql_2&#1111;email];
		$age = $sql_2&#1111;age];
		$inet_conn = $sql_2&#1111;inet_conn];
		$maps = $sql_2&#1111;maps];
		$weapons = $sql_2&#1111;weapons];
		$name = $sql_2&#1111;name];
		$skills = $sql_2&#1111;skills];
		?>
		<form action="modules.php?modules=your_account&op=udate_info" method="POST">
		Name:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="name" value=<?php echo ""$name""; ?>>
		<br><br>
		Age:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="age" maxlength="3" value=<?php echo ""$age""; ?>>
		<br><br>
		Email:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo "<input type="text" name="email" value="$email">"; ?>
		<br><br>
		Games:&nbsp;&nbsp;&nbsp;&nbsp;
		<select type="menu" name="games" multiple>
	 		<option value="America's Army">America's Army</option>
	 		<option value="Medal fo Honor: Allied Assault">Medal fo Honor: Allied Assault</option>
	 	</select>
		<br><br>
		Internet
		<br>
		Connection:&nbsp;&nbsp;&nbsp;&nbsp;
		<select type="pulldown" name="inet_conn">
	 		<option value="DIALUP">DIAL-UP</option>
	 		<option value="DSL">DSL</option>
	 		<option value="CABLE">CABLE</option>
	 		<option value="T1">T1</option>
	 		<option value="T3">T3</option>
		</select>
		<br><br>
		Favorite
		<br>
		Maps:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<select type="menu" name="maps" multiple>
			<option value="bridge_crossing">Bridge Crossing</option>
			<option value="hq_raid">Headquarters Raid</option>
			<option value="mout_mckenna">MOUT McKenna</option>
			<option value="collapsed_tunnel">Collapsed Tunnel</option>
			<option value="pipeline">Pipeline</option>
			<option value="insurgent_camp">Insurgent Camp</option>
			<option value="fls_assault">FLS Assault</option>
			<option value="mountain_pass">Mountain Pass</option>
			<option value="mountain_ambush">Mountain Ambush</option>
			<option value="swamp_raid">Swamp Raid</option>
			<option value="jrtc_farm_raid">JRTC Farm Raid</option>
			<option value="weapons_cache">Weapons Cache</option>
			<option value="river_basin">River Basin</option>
			<option value="weapons_cache_se">Weapons Cache SE</option>
			<option value="radio_tower">Radio Tower</option>
			<option value="bridge_se">Bridge SE</option>
			<option value="mountain_pass_se">Mountain Pass SE</option>
			<option value="pipeline_sf">Pipeline SF</option>
			<option value="sf_csar">SF CSAR</option>
			<option value="sf_recon">SF Recon</option>
			<option value="sf_hospital">SF Hospital</option>
			<option value="sf_sandstorm">SF SandStorm</option>
			<option value="sf_arctic">SF Arctic</option>
			<option value="sf_village">SF Village</option>
		</select>
		<br><br>
		Favorite
		<br>
		Weapons:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<select type="menu" size="8" name="_GUNS" multiple>
			<option value="m16a2">M16A2</option>
			<option value="m249">M249 "SAW"</option>
			<option value="m203">M203</option>
			<option value="m4a1">M4A1</option>
			<option value="sf_m4">SOPMOD M4 "SF"</option>
			<option value="m24">M24</option>
			<option value="m82">M82 "Barret"</option>
			<option value="spr">Special Forces Rifle "SPR"</option>
		</select>
		<br><br>
		Please tell us of any special skills on the computer or otherwise that you have that you could contribute to help us.:
		<br>
		<textarea name="skills" cols="50" rows="8"><?php echo "$skills"; ?></textarea>
		<br><br>
		<input type="submit" name="submit" value="SUBMIT">
		<?php
	&#125; else &#123;
		echo "You must login before you can manage your account.";
		include("blocks/login_block.php");
	&#125;
&#125;

function update_user_pass() &#123;
	if ($_SEESION&#1111;logged] == "logged") &#123;
		if ($_POST&#1111;new_pass] == $_POST&#1111;conf_new_pass] && $_POST&#1111;old_pass] == $_SESSION&#1111;pass]) &#123;
			$sql_1 = "REPLACE INTO members (user, pass) values ($_POST&#1111;user], md5($_POST&#1111;pass])) WHERE user=$_SESSION&#1111;user] and pass=$_SESSION&#1111;pass]";
			if (mysql_query($sql_1)) &#123;
				echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php?module=your_account"></head><body>";
				echo "Your password has been changed.";
				$_SESSION&#1111;user] = $_POST&#1111;user];
				$_SESSION&#1111;pass] = $_POST&#1111;pass];
			&#125; else &#123;
				echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php?module=your_account&op=chage_user_pass"></head><body>";
				echo "The old password you entered does not match with the username.";
			&#125;
		&#125; elseif ($_POST&#1111;pass] != $_POST&#1111;conf] or $_POST&#1111;old_pass] != $_SESSION&#1111;pass]) &#123;
			echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php?module=your_account&op=chage_user_pass"></head><body>";
			echo "The new passwords you entered do not match. Please Try again.";
		&#125; else &#123;
			echo "This action could not be performed at this time";
			echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php"></head><body>";
		&#125;
	&#125; else &#123;
		echo "You must login before you can manage your account.";
		include("blocks/login_block.php");
	&#125;
&#125;

function update_info() &#123;
	if ($_SESSION&#1111;logged] == "logged") &#123;
		$sql1 = "REPLACE INTO members (name, age, email, inet_conn, maps, weapons, skills) values ($_POST&#1111;name],$_POST&#1111;age], $_POST&#1111;email], $_POST&#1111;inet_con], $_POST&#1111;maps], $_POST&#1111;weapons], $_POST&#1111;skills]) WHERE user=$_SESSION&#1111;user] and pass=$_SESSION&#1111;pass]";
		if (mysql_query($sql1)) &#123;
			echo "Our records have been updated.\n Thank you.";
			echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php?module=your_account"></head><body>";
		&#125; else &#123;
			echo "This action could not be performed at this time";
			echo "</body><head><meta http-equiv="refresh" content="2;URL=modules.php"></head><body>";
		&#125;
	&#125; else &#123;
		echo "You must login before you can manage your account.";
		include("blocks/login_block.php");
	&#125;
&#125;

switch ( $op ) &#123;
	case "login":
		login();
		break;
	case "logout":
		logout();
		break;
	case "registration_form":
		registration_form();
		break;
	case "registration_submit":
		registration_submit();
		break;
	case "change_user_pass":
		change_user_pass();
		break;
	case "change_info":
		change_info();
		break;
	case "update_user_pass":
		update_user_pass();
		break;
	case "update_info":
		update_info();
		break;
	default:
		manage();
&#125;
?>
</body>
</html>

Posted: Thu Jan 20, 2005 11:13 pm
by harsha
the
default

should follow a break; other wise switch case goes in to a loop

I think that is the problem

Posted: Thu Jan 20, 2005 11:41 pm
by feyd
function register_submit() wasn't closed.

Posted: Fri Jan 21, 2005 11:40 am
by dreamline
Yep and that's exactly why i code my if elses like this:

Code: Select all

if ()
  &#123;
  &#125;
  else
  &#123;
     if ()
       &#123;
       &#125;
  &#125;
I'm going for readability :) And it's also easier for others to read, however that depends on the user though.. heheh

Posted: Fri Jan 21, 2005 1:20 pm
by Bill H
dreamline, I also use that form of bracing, and for the same reason, but it turns out we are in the minority. Something like 80% use the form that harsha does. There was a poll on that in the General Discussion forum some time ago.

Posted: Fri Jan 21, 2005 1:25 pm
by timvw
i believe the

if (..) {
} else {
}

was invented for saving space in a book on C.


With a decent editor you can easily transform the code to whatever style you prefer. And usually that editor will be able to close those brackets for you, remind you when a bracket is missing, etc.....

Posted: Fri Jan 21, 2005 1:52 pm
by feyd
it's actually from the days where you had a very limited amount of text on a screen, specifically lines. Waaaaay back in the stone-age of computing.

Posted: Fri Jan 21, 2005 1:59 pm
by dreamline
LOL, yea i remember those stone ages.. I even remember 8 bit ruling.. heheheh.. But if you have co-workers to work with and show your scripts then it's the way to go to brace them good so others can see easily what you are doing.. Or at least so i'm told.. heheh.. But i also believe i like it just better for me so i can read it more easily and trust me i have lotsa errors so it's easy for me to spot where the error is... :D