php form parse error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dave

    php form parse error

    Hi,
    I know i shouldn't work on php forms when i'm going on 30 hours of no sleep,
    but i did anyway. I'm trying to get the below to work, and i keep getting a
    parse error line 74, an unexpected
    ','
    there is none, so i'm assuming it's on another line, i've checked around,
    but don't see it. I'm probably missing something so simple that i'll call
    myself dumb for a month, but that's later, as of now i'd appreciate any
    help/suggestions.
    Thanks.
    Dave.


    <?php
    // orderform.php script
    // Created 20040730 by Dave M Mehler
    // Purpose: collect order form information, process it, data verification,
    // email designated users, and redirect visitor to a thank you page.
    ?>
    <html>
    <head>
    <title>streetfr eakzperformance product order</title>
    </head>
    <body bgcolor="#fffff f" text="#000000" link="#cbda74" vlink="#808040"
    alink="#808040" >
    <?
    $form = "
    <form action=\"orderf orm.php\" method=\"post\" >
    <input type=\"hidden\" name=\"seenform \" value=\"y\">
    <h1>Streetfreak zperformance Product Ordering Page</h1>
    <p>Thank you for wishing to purchase products produced by
    <b>streetfreakz performance.com </b>! Please fill out the following form,
    fields marked with a * (*) are required. You will recieve a confirmation
    email</p>
    Your Name:<br />
    <input type=\"text\" name=\"name\" size=\"20\" maxlength=\"20\ "
    value=\"\"><br />
    Your Email:<br />
    <input type=\"text\" name=\"email\" size=\"20\" maxlength=\"40\ "
    value=\"\"><br />
    Your Comments:<br />
    <textarea name=\"comments \" rows=\"3\" cols=\"30\"></textarea><br />
    <input type=\"submit\" value=\"submit! \">
    <input type=\"clear\" value=\"clear!\ ">
    </form>
    ";
    // If we haven't already seen the form ($seenform passed by hidden
    // form value), show the form.
    if ($seenform != "y") :
    print "$form";
    // The user has filled out the form. Now verify the information
    else :
    $error_flag = "n";
    // ensure that the name variable is not empty
    if ($name == "") :
    print "<font color=\"red\">* You forgot to enter your name!</font>
    <br />";
    $error_flag = "y";
    endif;
    // ensure that the email variable is not empty
    if ($email == "") :
    print "<font color=\"red\">* You forgot to enter your email!</font>
    <br />";
    $error_flag = "y";
    else :
    // convert all email alphabetical characters to lowercase
    $email = strtolower(trim ($email));
    // ensure the email address is of valid syntax
    if (! @eregi('^[0-9a-z]+'.
    '@'.
    '([0-9a-z-]+\.)+'.
    '([0-9a-z]){2,4}$', $email)) :
    print "<font color=\"red\">* You entered an invalid email
    address!</font> <br />";
    $error_flag = "y";
    endif;
    endif;
    endif;
    // If the $error_flag has been set, redisplay the form
    if ($error_flag == "y") :
    print "$form";
    else :
    // change $recipient to be the recipient of the form information
    $recipient = "testuser@examp le.com";
    // email subject
    $subject = "streetfreakzpe rformance product order request ($name)";
    // extra email headers
    $headers = "From: $email";
    // send the email or produce an error
    mail($recipient , $subject, $comments, $headers) or die("Could not send
    email!");
    // send the user an appropriate message
    print "Thank you", $name, "for taking a moment to send us your comments!";
    endif;
    ?>
    </body>
    </html>


  • Aphrael

    #2
    Re: php form parse error

    dave wrote:[color=blue]
    > print "Thank you", $name, "for taking a moment to send us your comments!";[/color]
    Concatenation is made with . and not with ,

    Aphrael
    --
    "La demande mondiale d’ordinateurs n’excédera pas cinq machines."
    (Thomas Watson, Fondateur d'IBM, 1945)

    Comment

    • Ian.H

      #3
      Re: php form parse error

      On Fri, 30 Jul 2004 14:19:14 +0000, dave wrote:
      [color=blue]
      > Hi,
      > I know i shouldn't work on php forms when i'm going on 30 hours of no sleep,
      > but i did anyway. I'm trying to get the below to work, and i keep getting a
      > parse error line 74, an unexpected
      > ','
      > there is none, so i'm assuming it's on another line, i've checked around,
      > but don't see it. I'm probably missing something so simple that i'll call
      > myself dumb for a month, but that's later, as of now i'd appreciate any
      > help/suggestions.
      > Thanks.
      > Dave.[/color]


      [ snip ]

      [color=blue]
      > print "Thank you", $name, "for taking a moment to send us your comments!";[/color]


      [ snip ]


      Ahh Perl coder eh? =)

      PHP doens't recognise commas for concatenation purposes, but rather the
      "normal" . (dot).


      HTH.



      Regards,

      Ian

      --
      Ian.H
      digiServ Network
      London, UK


      Comment

      • Andy Hassall

        #4
        Re: php form parse error

        On Fri, 30 Jul 2004 16:11:09 GMT, "Ian.H" <ian@WINDOZEdig iserv.net> wrote:
        [color=blue]
        >On Fri, 30 Jul 2004 14:19:14 +0000, dave wrote:
        >[color=green]
        >> I know i shouldn't work on php forms when i'm going on 30 hours of no sleep,
        >> but i did anyway. I'm trying to get the below to work, and i keep getting a
        >> parse error line 74, an unexpected
        >> ','
        >> there is none, so i'm assuming it's on another line, i've checked around,
        >> but don't see it. I'm probably missing something so simple that i'll call
        >> myself dumb for a month, but that's later, as of now i'd appreciate any
        >> help/suggestions.[/color]
        >
        >[ snip ]
        >[color=green]
        >> print "Thank you", $name, "for taking a moment to send us your comments!";[/color]
        >
        >[ snip ]
        >
        >Ahh Perl coder eh? =)
        >
        >PHP doens't recognise commas for concatenation purposes, but rather the
        >"normal" . (dot).[/color]

        Although something similar with echo:

        echo "Thank you", $name, "for taking a moment to send us your comments!";

        ... would work, as it takes a variable number of arguments and prints them
        all.

        --
        Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
        http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

        Comment

        Working...