Jump to content

[SOLVED] Parse error: syntax error, unexpected '!' in


dropfaith

Recommended Posts

its on line 73 this scripott is part of a huge user system i have that was working up until a few days ago

i had someone else working on things a bit for me now its all messed up

 

well the user system at least

this is line 69 thru 76  73 being this

!valid_email($email) || $password != $password2 || user_exists($username))

function registerNewUser($username, $password, $password2, $email)
{
global $seed;
if (!valid_username($username) || !valid_password($password) 
		!valid_email($email) || $password != $password2 || user_exists($username))
{
	return false;
}

<?php
##### User Functions #####
function changePassword($username,$currentpassword,$newpassword,$newpassword2){
global $seed;
if (!valid_username($username) || !user_exists($username))
{
	return false;
}
if (! valid_password($newpassword) || ($newpassword != $newpassword2)){
	return false;
}
// we get the current password from the database
$query = sprintf("SELECT password FROM login WHERE username = '%s' LIMIT 1",
	mysql_real_escape_string($username));
$result = mysql_query($query);
$row= mysql_fetch_row($result);
// compare it with the password the user entered, if they don't match, we return false, he needs to enter the correct password.
if ($row[0] != sha1($currentpassword.$seed)){
	return false;
}
// now we update the password in the database
$query = sprintf("update login set password = '%s' where username = '%s'",
	mysql_real_escape_string(sha1($newpassword.$seed)), mysql_real_escape_string($username));
if (mysql_query($query))
{
	return true;
}else {return false;}
return false;
}
function user_exists($username)
{
if (!valid_username($username))
{
	return false;
}
$query = sprintf("SELECT loginid FROM login WHERE username = '%s' LIMIT 1",
	mysql_real_escape_string($username));
$result = mysql_query($query);
if (mysql_num_rows($result) > 0)
{
	return true;
} else
{
	return false;
}
return false;
}
function activateUser($uid, $actcode)
{
$query = sprintf("select activated from login where loginid = '%s' and actcode = '%s' and activated = 0  limit 1",
	mysql_real_escape_string($uid), mysql_real_escape_string($actcode));
$result = mysql_query($query);
if (mysql_num_rows($result) == 1)
{
	$sql = sprintf("update login set activated = '1'  where loginid = '%s' and actcode = '%s'",
		mysql_real_escape_string($uid), mysql_real_escape_string($actcode));
	if (mysql_query($sql))
	{
		return true;
	} else
	{
		return false;
	}
} else
{
	return false;
}
}
function registerNewUser($username, $password, $password2, $email)
{
global $seed;
if (!valid_username($username) || !valid_password($password) 
		!valid_email($email) || $password != $password2 || user_exists($username))
{
	return false;
}
$code = generate_code(20);
$sql = sprintf("insert into login (username,password,email,actcode) value ('%s','%s','%s','%s')",
	mysql_real_escape_string($username), mysql_real_escape_string(sha1($password . $seed))
	, mysql_real_escape_string($email), mysql_real_escape_string($code));
if (mysql_query($sql))
{
	$id = mysql_insert_id();
	if (sendActivationEmail($username, $password, $id, $email, $code))
	{
		return true;
	} else
	{
		return false;
	}
} else
{
	return false;
}
return false;
}
function lostPassword($username, $email)
{
global $seed;
if (!valid_username($username) || !user_exists($username) || !valid_email($email))
{
	return false;
}
$query = sprintf("select loginid from login where username = '%s' and email = '%s' limit 1",
	$username, $email);
$result = mysql_query($query);
if (mysql_num_rows($result) != 1)
{
	return false;
}
$newpass = generate_code(;
$query = sprintf("update login set password = '%s' where username = '%s'",
	mysql_real_escape_string(sha1($newpass.$seed)), mysql_real_escape_string($username));
if (mysql_query($query))
{
		if (sendLostPasswordEmail($username, $email, $newpass))
	{
		return true;
	} else
	{
		return false;
	}
} else
{
	return false;
}
return false;
}
?>





Link to comment
Share on other sites

   if (!valid_username($username) || !valid_password($password) ||
         !valid_email($email) || $password != $password2 || user_exists($username))
   {

 

You left the || off of !valid_password($password).  The code above is the fixed version; compare it to yours.

Link to comment
Share on other sites

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.