Lassie Posted February 22, 2008 Share Posted February 22, 2008 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 Quote Link to comment Share on other sites More sharing options...
GuitarGod Posted February 22, 2008 Share Posted February 22, 2008 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 Quote Link to comment Share on other sites More sharing options...
Lassie Posted February 22, 2008 Author Share Posted February 22, 2008 Thanks . That cured the parse error, but using a different verion of my ide gives these curiosities ?>䡐⁐慗湲湩㩧†湕湫睯⡮㨩唠慮汢潴氠慯祤慮業楬牢牡⁹⸧瀯灨束㉤搮汬‧桔灳捥晩敩潭畤敬挠畯摬渠瑯戠潦湵椠湕湫睯湯氠湩ਰ Any ideas? Quote Link to comment Share on other sites More sharing options...
revraz Posted February 22, 2008 Share Posted February 22, 2008 Load the file in notepad and see what they are. And remove //error line at the end, there is no point on having that outside of your PHP. Quote Link to comment Share on other sites More sharing options...
Lassie Posted February 22, 2008 Author Share Posted February 22, 2008 No funny chrs shown in notepad. The '//error' is not in the code. I added it to the post for clarity. Thanks for comenting Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.