Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts

    Need help, with php complete newbie

    I have configured a contact form for a website, and on checking the form I receive this error.

    Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/tenemb33/public_html/contact_process.php on line 65

    the line it refers to is this in the code snippet below.

    $name = $_POST["name"];

    is this easy to fix? if so how would I fix it? I can post more of the code if needed.



    if ($check_all_patterns AND !$forbidden) $forbidden = preg_match("/(%0a|%0d|\\n+|\\r+)/i", $str);
    if ($forbidden)
    {
    echo "<font color=red><center><h3>STOP! Message not sent.</font></h3><br><b>
    The text you entered is forbidden, it includes one or more of the following:
    <br><textarea rows=9 cols=25>";
    foreach ($patterns as $key => $value) echo $value."\n";
    echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
    </b><br><br><br> exit();
    }
    }
    foreach ($_REQUEST as $value) is_forbidden($value);

    $name = $_POST["name"];
    $email = $_POST["email"];
    $thesubject = $_POST["thesubject"];
    $themessage = $_POST["themessage"];

    $success_sent_msg='<p align="center"><strong>&nbsp;</strong></p>
    <p align="center"><strong>Your message has been successfully sent to us<br>
    </strong> and we will reply as soon as possible.</p>
    <p align="center">A copy of your query has been sent to you.</p>
    <p align="center">Thank you for contacting us.</p>';

    $replymessage = "Hi $name

  • #2
    Regular Coder
    Join Date
    Dec 2007
    Posts
    145
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Remove the "'s

    Code:
    $name = $_POST["name"];
    Should be

    Code:
    $name = $_POST[name];

  • #3
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts

    re

    OK thanks I will try that. Do I need to remove all the "" from all the fields below?

    $name = $_POST["name"];
    $email = $_POST["email"];
    $thesubject = $_POST["thesubject"];
    $themessage = $_POST["themessage"];

    Well I will try both ways. Thanks again.

  • #4
    Regular Coder
    Join Date
    Dec 2007
    Posts
    145
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Actually,

    Code:
    $name = $_POST["name"];
    is usually ok.

    It's mostly when you have like:

    Code:
    echo "$_POST["mydata"]";
    But I don't see that you are mixing up any double quotes, so that's the only problem I can think of.

    Try it real quick, and keep me posted here.

  • #5
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts

    re

    Done that, and now I am getting a new error on line 70.

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/tenemb33/public_html/contact_process.php on line 70

    $name = $_POST[name];
    $email = $_POST[email];
    $thesubject = $_POST[thesubject];
    $themessage = $_POST[themessage];


    Line 70
    $success_sent_msg='<p align="center"><strong>&nbsp;</strong></p>
    <p align="center"><strong>Your message has been successfully sent to us<br>
    </strong> and we will reply as soon as possible.</p>
    <p align="center">A copy of your query has been sent to you.</p>
    <p align="center">Thank you for contacting us.</p>';

  • #6
    Regular Coder
    Join Date
    Dec 2007
    Posts
    145
    Thanks
    5
    Thanked 5 Times in 5 Posts
    I'm re-doing all the quotes on that part...

    Code:
    $success_sent_msg="<p align=\"center\"><strong>&nbsp;</strong></p>
    <p align=\"center\"><strong>Your message has been successfully sent to us<br>
    </strong> and we will reply as soon as possible.</p>
    <p align=\"center\">A copy of your query has been sent to you.</p>
    <p align=\"center\">Thank you for contacting us.</p>";

    Try that...

    That's the way of coding I'm used to, so I know it'll work.

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by nobackseat88 View Post
    Remove the "'s

    Code:
    $name = $_POST["name"];
    Should be

    Code:
    $name = $_POST[name];
    Disregard this, this information is not correct.

    You have an open string right here:
    PHP Code:
    echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
    </b><br><br><br> exit(); 
    Close it before the exit call, otherwise it considers upto and including the $_POST[" before the name as a part of the string.

    Edit:
    Holy, a lot of posts snuck in there.
    As well, you have a close brace with no matching open in this block right below the foreach on you're request. You probably shouldn't use request, choose a post or get since before PHP6 you can't remove the cookie from it without manual work.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #8
    Regular Coder
    Join Date
    Dec 2007
    Posts
    145
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Wow, good eye, Fou-Lou.

    PHP is never accurate with the line numbering.

    Sometimes the quotes are a problem though, at least in my experience (probably measly compared to yours. :P)

    It was the only thing I thought could potentially be the problem.

    Sorry for any inconvenience or trouble I caused you. :P

  • #9
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts

    re

    Is this what you mean by closing?

    echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
    </b><br><br><br>" exit();

  • #10
    Regular Coder
    Join Date
    Dec 2007
    Posts
    145
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Code:
    echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
    </b><br><br><br>";
     exit();

  • #11
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts

    re

    right I will change it to that, thanks.
    Maybe I should make the quotes come back too which I had removed.

  • #12
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by nobackseat88 View Post
    Wow, good eye, Fou-Lou.

    PHP is never accurate with the line numbering.

    Sometimes the quotes are a problem though, at least in my experience (probably measly compared to yours. :P)

    It was the only thing I thought could potentially be the problem.

    Sorry for any inconvenience or trouble I caused you. :P
    Thats ok.
    Line numbers are actually always correct, the problem is the root cause. In this case, its from an open string further up, but the interpreter cannot see it until it has reached the line in question (65 in this situation). The error itself is on line 60.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #13
    Regular Coder
    Join Date
    Dec 2007
    Posts
    145
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Maybe I should make the quotes come back too which I had removed.
    Yep, they were not the problem.

  • #14
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts

    re

    thanks guys, reckon it works good now, well I got an thankyou from the form.


  •  

    Posting Permissions

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