Web Hosting Talk







View Full Version : php "parse error", how do i fix it?


latheesan
07-04-2005, 02:33 PM
Hi, this is my piece of code to register for a user account. for some reason, i keep getting a strange error saying that

Parse error: parse error in root\htdocs\users\register.php on line 90


this is my php script


79
<?php

//Connect to database
include("db.php");

//Set some variables
$name = $_POST['name'];
$email = $_POST['email'];
$user = $_POST['user'];
$pass = $_post['password'];
$id = $_PSOT['id'];

//Email validation function
function valid($email){
if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$", $email)) {
return true;
}else{
return false;
}
}

//Some error checking
if (!$name) {
echo "You did not enter your real <b>Name</b>, Go back and try again";
exit();
}
if (!$email) {
echo "You did not enter a valid <b>E-Mail Address</b>, Go back and try again";
exit();
}
if (valid($email)) {
echo "You entered an <b>Invalid</b> E-Mail Address, Format Should be you@domain.com<br><br>Go back and try again";
exit();
}
if (!$user) {
echo "You did not enter your <b>Username</b>, Go back and try again";
exit();
}
if (!$pass) {
echo "You did not enter your <b>Password</b>, Go back and try again";
exit();
}else{

//username check
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$user'");
$username_check = mysql_num_rows($sql_username_check);
if ($username_check > 0) {
echo "The username you chose is already in use!<br><br>Please go back and try again.";
exit();
}
else {

//MD5 encrypt password
$db_pass = md5($pass);

//Write information to database
mysql_query("INSERT INTO user (name, email, username, password, id, active) VALUES('$name', '$email', '$user', '$db_pass', '$id', 'no')") or die(mysql_error());

//E-Mail validation

$subject = "MySite Account Activation";
$message = "Dear $name,

Please click on the link below to activate your account:

http://www.mysite.com/activate.php?id=$id

Once activated, you can login with the following information

Username: $user
Password: $pass

Regards,
MySite, http://www.MySite.com

<b>Please note: This is an automated response, Please do not reply!</b>

//Send email to user
mail('$email', '$subject', '$message', 'From: Admin<admin@mysite.com>\nX-Mailer: PHP/' . phpversion());

//Include finsih function
include ('finish.php');
}
}

//Close database connection
mysql_close();

?>


When i checked it, the line 90 is this part "?>"

now hows that causing a problem?

Mniphtiik
07-04-2005, 02:49 PM
Guessing that the "79" means that that's line 79... (if the <?php is line 1 then that's wrong because there are only 89 lines!)

<?php

//Connect to database
include("db.php");

//Set some variables
$name = $_POST['name'];
$email = $_POST['email'];
$user = $_POST['user'];
$pass = $_post['password'];
$id = $_PSOT['id']; // Change this to $_POST

You put $_PSOT not $_POST on the bottom line of the code I just put.

Just a wee spelling mistake ;)

latheesan
07-04-2005, 03:28 PM
hehehhe crazyyyyy

latheesan
07-04-2005, 03:36 PM
sorry friend, it didnt work :(

latheesan
07-04-2005, 03:43 PM
plzzz help

fozzy
07-04-2005, 03:51 PM
Its doing something funny when I post with the php tags so I took them out. Make sure you use escape characters.






$message = "Dear $name,

Please click on the link below to activate your account:

<a href=\"http://www.mysite.com/activate.php?id=\" target=\"_blank\">http://www.mysite.com/activate.php?id=</a>$id

Once activated, you can login with the following information

Username: $user
Password: $pass

Regards,
MySite, <a href=\"http://www.MySite.com\" target=\"_blank\">http://www.MySite.com</a>

<b>Please note: This is an automated response, Please do not reply!</b>

latheesan
07-04-2005, 04:02 PM
ohhh,

let me try that then

latheesan
07-04-2005, 04:08 PM
sowie that didnt work either

latheesan
07-04-2005, 04:14 PM
anymore suggestion anyone plz?

fastduke
07-04-2005, 11:46 PM
close $message and escape your quotes like noted above.(you're missing "; at the end). I think that'll fix your error


$message = "Dear $name,

Please click on the link below to activate your account:

<a href=\"http://www.mysite.com/activate.php?id=\" target=\"_blank\">http://www.mysite.com/activate.php?id=</a>$id

Once activated, you can login with the following information

Username: $user
Password: $pass

Regards,
MySite, <a href=\"http://www.MySite.com\" target=\"_blank\">http://www.MySite.com</a>

<b>Please note: This is an automated response, Please do not reply!</b>";

Xenatino
07-05-2005, 03:52 AM
Also, just a note. You need to add \n everytime you want a new line in an email, otherwise it will all come out as one long line.