SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: parse error

  1. #1
    SitePoint Member claudie's Avatar
    Join Date
    Jun 2007
    Location
    Nairobi, kenya
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question parse error

    am new in use of php scripts I got the following error after developing one script

    syntax error, unexpected $end in /hsphere/local/home/frankhop/contact.php on line 47

    the code is as below;
    <?php
    if (!isset($_POST['submit_form'])):
    $to="my email.com";
    $from = $_REQUEST['email'] ;
    $name = $_REQUEST['firstname'] ;
    $Telephone = $_REQUEST['Telephone'] ;
    $Date = $_REQUEST['Date'] ;
    $nights= $_REQUEST['nights'] ;
    $headers = "From: $from";
    $subject = "My Enquiries";

    $fields = array();
    $fields{"email"} = "Email Address";
    $fields{"firstname"} = "First Name";
    $fields{"lastname"} = "Last Name";
    $fields{"Telephone"} = "Telephone";
    $fields{"Date"} = "Arrival Date";
    $fields{"nights"} = "No of Nights";
    $fields{"Adults"} = "No of Adults";
    $fields{"child"} = "No of Children";
    $fields{"comments"} = "Your Enquiry";

    $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

    $headers2 = "From: imy email.com";
    $subject2 = "Thank you for contacting us";
    $autoreply = "Thank you for contacting us.
    Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at mywebadress.com";

    if($from == '') {print "You have not entered an email, please go back and try again";}
    else {
    if($name == '') {print "You have not entered a name, please go back and try again";}
    else {
    if($Tel == '') {print "You have not entered your Telephone Number, please go back and try again";}
    else {
    if($Date == '') {print "You have not entered the arrival date, please go back and try again";}
    else {
    if($nights== '') {print "You have not entered Number of Nights, please go back and try again";}
    else {
    $send = mail($to, $subject, $body, $headers);
    $send2 = mail($from, $subject2, $autoreply, $headers2);
    if($send)
    {header( "Location: http://mywebadress/thankyou.html" );}
    else
    {print "We encountered an error sending your mail, please notify admin@myemail"; }
    }
    }
    ?>

    Is there anything I omited?
    pls somebody help

  2. #2
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The last } should be endif;

  3. #3
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Welcome to forum.
    Why u repeat if statement,
    use elseif.

  4. #4
    SitePoint Member claudie's Avatar
    Join Date
    Jun 2007
    Location
    Nairobi, kenya
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by praetor View Post
    The last } should be endif;
    is the end if between the last}} or...
    Thx for your quick response
    learning will never cease

  5. #5
    SitePoint Member claudie's Avatar
    Join Date
    Jun 2007
    Location
    Nairobi, kenya
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mmarif4u View Post
    Welcome to forum.
    Why u repeat if statement,
    use elseif.
    Hi
    Kindly lemmi know at which line should i not use the if and insert else if
    I appreciate your quick, response
    learning will never cease

  6. #6
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    look at ur these lines:
    PHP Code:
    if($from == '') {print "You have not entered an email, please go back and try again";}
    else {
    if(
    $name == '') {print "You have not entered a name, please go back and try again";}
    else {
    if(
    $Tel == '') {print "You have not entered your Telephone Number, please go back and try again";}
    else {
    if(
    $Date == '') {print "You have not entered the arrival date, please go back and try again";}
    else {
    if(
    $nights== '') {print "You have not entered Number of Nights, please go back and try again";}
    else { 
    try it like this way:
    PHP Code:
    if($from == '') {print "You have not entered an email, please go back and try again";}
    elseif(
    $name == '') {print "You have not entered a name, please go back and try again";}
    elseif(
    $Tel == '') {print "You have not entered your Telephone Number, please go back and try again";}
    elseif(
    $Date == '') {print "You have not entered the arrival date, please go back and try again";}
    elseif(
    $nights== '') {print "You have not entered Number of Nights, please go back and try again";}
    else { 

  7. #7
    SitePoint Member claudie's Avatar
    Join Date
    Jun 2007
    Location
    Nairobi, kenya
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mmarif4u View Post
    look at ur these lines:
    PHP Code:
    if($from == '') {print "You have not entered an email, please go back and try again";}
    else {
    if(
    $name == '') {print "You have not entered a name, please go back and try again";}
    else {
    if(
    $Tel == '') {print "You have not entered your Telephone Number, please go back and try again";}
    else {
    if(
    $Date == '') {print "You have not entered the arrival date, please go back and try again";}
    else {
    if(
    $nights== '') {print "You have not entered Number of Nights, please go back and try again";}
    else { 
    try it like this way:
    PHP Code:
    if($from == '') {print "You have not entered an email, please go back and try again";}
    elseif(
    $name == '') {print "You have not entered a name, please go back and try again";}
    elseif(
    $Tel == '') {print "You have not entered your Telephone Number, please go back and try again";}
    elseif(
    $Date == '') {print "You have not entered the arrival date, please go back and try again";}
    elseif(
    $nights== '') {print "You have not entered Number of Nights, please go back and try again";}
    else { 
    thx dear lemmi try it out
    learning will never cease


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •