Error
Posted: Fri May 26, 2006 5:42 pm
Hi all
This is my code i have tryed many different things
i have moved the { added if and added ( but i jus clear one error and get another please help
This is my error
Parse error: parse error, unexpected T_ELSE in /home/reeceth/public_html/game/login.php on line 75
or it changes and says that i have a }
and thats what i put in to stop the T_ELSE and it wants me to take it out so when i take it out i get a T_ELSE error again so i cant win
Thanks Reece
thanks
This is my code i have tryed many different things
i have moved the { added if and added ( but i jus clear one error and get another please help
Code: Select all
<?php
// Connect to the database
mysql_connect($server,$dbuser,$dbpass) or die ("Could not establish connection"); // make connection
mysql_select_db($dbname); // select database
// convert posted info to easy to use variables
$user = $_REQUEST['username'];
$pass = $_REQUEST['password'];
// strip away any dangerous tags
$user=strip_tags($user);
$pass=strip_tags($pass);
// remove spaces from variables
$user=str_replace(" ","",$user);
$pass=str_replace(" ","",$pass);
// remove escaped spaces
$user=str_replace("%20","",$user);
$pass=str_replace("%20","",$pass);
// add slashes to stop hacking
$user=addslashes($user);
$pass=addslashes($pass);
// hash users password for security (32 chars random - md5)
$pass=md5($pass);
// search database to check for user
$request = "SELECT * FROM registered_members WHERE password='".$pass."' AND name='".$user."'";
// hand over the request
$results = mysql_query($request);
// if mysql returns any number of rows great than 0 then there is a succesful login
if(mysql_num_rows($results))
{
// get users id
$getid = "SELECT * FROM registered_members WHERE name ='".$user."' LIMIT 1";
$getidexec = mysql_query($getid);
while($r=mysql_fetch_array($getidexec)){
$userid = $r[userid];
}
{
//sets date and time variables
$last = gmdate("Y-m-d");
$time = gmdate("H:i", time() + $zone);
//build and issue the query
$sql ="INSERT INTO log_login VALUES
('$user', '$last', '$time', '$REMOTE_ADDR')";
$result2 = @mysql_query($sql);
// set a cookie
setcookie( "id", "$id", time()+3600, "/", "", 0 );
setcookie( "user", "$user", time()+7200, "/", "", 0 );
echo "Welcome, $user you loged in succesfully.<br><br><a href=\"test.php?username=$user\">Continue...</a>";
}
else // only happens if not a succesful username and password match
{
// login failed so display error message and kill script
die("Username and passwords do not match our records<br><br><a href=\"loginform.htm\">Click to retry ?");
}
?>Parse error: parse error, unexpected T_ELSE in /home/reeceth/public_html/game/login.php on line 75
or it changes and says that i have a }
and thats what i put in to stop the T_ELSE and it wants me to take it out so when i take it out i get a T_ELSE error again so i cant win
Thanks Reece
thanks