Jump to content

Cant find parse error


Lassie

Recommended Posts

I have a function that gives a parse error on the last line 'unexpected $end in ln 56'

I cant see why. Can anyone help please.


<?php

function user_account($first_name,$last_name,$email)
{
//create short variables.
$fn=$first_name;
$ln=$last_name;
$e=$email;

//generate password
// Create a new, random password.
	$p = substr ( md5(uniqid(rand(),1)), 3, 10);
//register details
if ($fn && $ln && $e && $p) 
{ // If everything's OK.

	//connect to db registration
	require_once ('./reg/mysql_connect.php'); // Connect to the database.
	// Make sure the email address is available.Maybe already checked
	$query = "SELECT user_id FROM users WHERE email='$e'";		
	$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

	if (mysql_num_rows($result) == 0) 
{ // Available.

		// Create the activation code.
		$a = md5(uniqid(rand(), true));
		//Modify update for password by taking out md5, already done.

		// Add the user.
		$query = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', m'$p', '$fn', '$ln', '$a', NOW() )";		
		$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

		if (mysql_affected_rows() == 1) 
		{ // If it ran OK.

		//add from
		$to = $_POST['email'];
	 		$subj = "Activating Your Account";
	 		$mess = "Thank you. You are now registered with e-Books4U<br />To activate your account, please click on this link;<br />\n\n";
	 		$mess .="<a href='http://217.46.159.226/e_cart21/reg/activate.php?x=" . mysql_insert_id() ."&y=$a'>Activate account</a>";
		$mess.="<br />Your password for login is, $p\n\n";

		$headers = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

		 mail($to,$subj,$mess,$headers);

		return true;

	}else{
			return false;
		}
	}
}
?>//error line

Link to comment
Share on other sites

I think you're missing a bracket at the end.

 

Try

<?php

function user_account($first_name,$last_name,$email)
{
//create short variables.
$fn=$first_name;
$ln=$last_name;
$e=$email;

//generate password
// Create a new, random password.
	$p = substr ( md5(uniqid(rand(),1)), 3, 10);
//register details
if ($fn && $ln && $e && $p) 
{ // If everything's OK.

	//connect to db registration
	require_once ('./reg/mysql_connect.php'); // Connect to the database.
	// Make sure the email address is available.Maybe already checked
	$query = "SELECT user_id FROM users WHERE email='$e'";		
	$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

	if (mysql_num_rows($result) == 0) 
{ // Available.

		// Create the activation code.
		$a = md5(uniqid(rand(), true));
		//Modify update for password by taking out md5, already done.

		// Add the user.
		$query = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', m'$p', '$fn', '$ln', '$a', NOW() )";		
		$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

		if (mysql_affected_rows() == 1) 
		{ // If it ran OK.

		//add from
		$to = $_POST['email'];
	 		$subj = "Activating Your Account";
	 		$mess = "Thank you. You are now registered with e-Books4U<br />To activate your account, please click on this link;<br />\n\n";
	 		$mess .="<a href='http://217.46.159.226/e_cart21/reg/activate.php?x=" . mysql_insert_id() ."&y=$a'>Activate account</a>";
		$mess.="<br />Your password for login is, $p\n\n";

		$headers = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

		 mail($to,$subj,$mess,$headers);

		return true;

	}else{
			return false;
		}
	}
}
}
?>//error line

Link to comment
Share on other sites

Thanks . That cured the parse error, but using a different verion of my ide gives these curiosities

?>䡐⁐慗湲湩㩧†湕湫睯⡮㨩唠慮汢⁥潴氠慯⁤祤慮業⁣楬牢牡⁹⸧瀯灨束㉤搮汬‧‭桔⁥灳捥晩敩⁤潭畤敬挠畯摬渠瑯戠⁥潦湵⹤਍椠湕湫睯湯氠湩⁥ਰ

Any ideas?

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.