Jump to content


Photo

Keep getting an error??


  • Please log in to reply
8 replies to this topic

#1 mehole

mehole
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 21 August 2006 - 12:04 PM

I am very new to php so go easy if these mistakes are stupid  ;)
I've got this script:
<?PHP 

$fname = $_POST['fname']; 
$lname = $_POST['lname'];
$email = $_POST['email']; 
$phone = $_POST['phone'];
$wmonth = $_POST['month'];
$wdate = $_POST['date'];
$wyear = $_POST['year'];
$umonth = $_POST['month2'];
$udate = $_POST['date2'];
$uyear = $_POST['year2'];
$adults = $_POST['adults'];
$child = $_POST['child'];
$submit = $_POST['submit']; 

//enter the email that the form should be sent to
$emailTo = 'my@email.com'; 
//enter the email's subject
$emailSubject = "Email subject"; 

$emailBody = "Name: $fname $lname\n";
 "Email: $email\n";
 "Phone Number: $phone\n";
 "Dates wanted: $wmonth-$wdate-$wyear\n";
 "Until: $umonth-$udate-$year";
 "Number of Adults: $adults";
 "Number of Children: $child";

$emailHeader = "From: $fname $lname; $email\n";
 "Reply-To: $fname $lname\n";
 "MIME-Version: 1.0\n";
 "Content-type: text/plain; charset=\"ISO-8859-1\"\n";
 "Content-transfer-encoding: quoted-printable\n"; 

mail($emailTo, $emailSubject, $emailBody, $emailHeader); 

if ($_POST['submit']) { 

	if (($fname=="") || ($lname=="")|| ($email=="") || ($wmonth=="") || ($wdate=="") || ($wyear=="") || ($umonth=="") || ($udate=="") || ($uyear=="") || ($adults==""))  {
print "Error: Please complete all of the required fields.";
outputform();
	}
	
	else {
//URL of where the user is redirected to
header("Location: http://www.mysite.com"); 
exit; 
}
?>

But i keep getting this error:

Parse error: parse error, unexpected $ in /home/content/m/e/h/mehole8338/html/Bookingform/enquiry.php on line 51


But all that is on line 51 is
?>
so i don't understand what is wrong?
Can someone help me out?
Many thanks
Mike

#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 21 August 2006 - 12:07 PM

I'm pretty sure:

$emailBody = "Name: $fname $lname\n";
 "Email: $email\n";
 "Phone Number: $phone\n";
 "Dates wanted: $wmonth-$wdate-$wyear\n";
 "Until: $umonth-$udate-$year";
 "Number of Adults: $adults";
 "Number of Children: $child";

Should Be:

$emailBody = "Name: $fname $lname\n
 Email: $email\n
 Phone Number: $phone\n
 Dates wanted: $wmonth-$wdate-$wyear\n
 Until: $umonth-$udate-$year
 Number of Adults: $adults
 Number of Children: $child";

Also, change:

if ($_POST['submit']) { 

To:

if (isset($_POST['submit'])) { 

edit (after seeing scott's reply)-

Change:

$emailHeader = "From: $fname $lname; $email\n";
 "Reply-To: $fname $lname\n";
 "MIME-Version: 1.0\n";
 "Content-type: text/plain; charset=\"ISO-8859-1\"\n";
 "Content-transfer-encoding: quoted-printable\n"; 

To:

$emailHeader .= "From: $fname $lname; $email\n"
 ."Reply-To: $fname $lname\n"
 ."MIME-Version: 1.0\n"
 ."Content-type: text/plain; charset=\"ISO-8859-1\"\n"
 ."Content-transfer-encoding: quoted-printable\n";


#3 ScottRiley

ScottRiley
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 21 August 2006 - 12:24 PM

Yeah, you need to sort your strings out, there's no need for closing the quotes and adding the semicolon, just wrap the whole string in a set of quotes.  you do the same for your e-mail header variable too, change it so that the string is wrapped in quotes, without the semicolons at the end, like hostfreak said.

#4 mehole

mehole
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 21 August 2006 - 01:21 PM

Ok, i've changed what you said but i'm still getting the same error:

Parse error: parse error, unexpected $ in /home/content/m/e/h/mehole8338/html/Bookingform/enquiry.php on line 51

I dont understand what's wrong?

#5 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 21 August 2006 - 01:23 PM

you are missing a closing '}' on your if statement

change
<?php
if ($_POST['submit']) { 

	if (($fname=="") || ($lname=="")|| ($email=="") || ($wmonth=="") || ($wdate=="") || ($wyear=="") || ($umonth=="") || ($udate=="") || ($uyear=="") || ($adults==""))  {
print "Error: Please complete all of the required fields.";
outputform();
	}
	
	else {
//URL of where the user is redirected to
header("Location: http://www.mysite.com"); 
exit; 
}
?>

to

<?php
if ($_POST['submit']) { 

	if (($fname=="") || ($lname=="")|| ($email=="") || ($wmonth=="") || ($wdate=="") || ($wyear=="") || ($umonth=="") || ($udate=="") || ($uyear=="") || ($adults==""))  {
print "Error: Please complete all of the required fields.";
outputform();
	}
	
	else {
//URL of where the user is redirected to
header("Location: http://www.mysite.com"); 
exit;
	}
}
?>

follow me on twitter @PHPsycho

#6 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 21 August 2006 - 01:27 PM

Can't believe I missed that

#7 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 21 August 2006 - 01:32 PM

You have clearly not missed enough closing braces in your time!!!!!!

the error always points to the last line of the script!!! ;)
follow me on twitter @PHPsycho

#8 mehole

mehole
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 21 August 2006 - 01:41 PM

thanks guys, i'm not getting the error anymore, but it is just showing a blank screen when I hit submit, the e-mail is being sent but it is not going to the page i redirected it to?

#9 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 21 August 2006 - 01:46 PM

check you logic in the if statement... just using =="" sometimes aint good enough..
follow me on twitter @PHPsycho




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users