Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
  1. #1
    Member
    Join Date
    Sep 2006
    Posts
    39
    Member #
    13897
    Hello people,
    I have designed my friend a website and ive included some PHP scripting for a form. I got this from a tutorial on the web! I get this error when you try and get on the page!
    Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /homepages/45/d176902828/htdocs/contact.php on line 130
    I have attached my contact.php file but do not know what ive done wrong? im a PHP newbie so be gentle!
    Anyone got any ideas? The website is www.morcomltd.co.uk
    Cheers for your Wisdom!
    Edd.

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    It looks like your problems are starting out on line 130 ...

    This part:

    PHP Code:
    <?php
    $Error 
    $_GET['error'];
    if(isset(
    $Error)) {
    echo 
    '<fieldset><legend>Contact Form</legend>'."n";
    echo 
    '<form action="thank_you.php" method="post">'."n";
    echo 
    '<p><label for="name"><strong>Name :</strong></label><br />'."n";
    echo 
    '<input type="text" name="name" id="name" tabindex="1" size="40" value="'.$_SESSION['name'].'" /></p>'."nn";

    .
    .
    .
    I think you need to change your quote system and do more like
    this on all of your echo lines. Note the use of single quotes within
    your HTML and \n for new lines. You can also use one echo and
    insert HTML between echo" and "; ...

    PHP Code:
    <?php
    $Error 
    $_GET['error'];
    if(isset(
    $Error)) {
    echo
    "
    <fieldset><legend>Contact Form</legend>\n
    <form action='thank_you.php' method='post'>\n
    <p><label for='name'><strong>Name :</strong></label><br />\n
    <input type='text' name='name' id='name' tabindex='1' size='40' value='.
    $_SESSION['name'].' /></p>\n
    "
    ;
    .
    .
    .
    .


  4. #3
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Hmmm, I think it could possibly be this part on line 128:

    PHP Code:
    echo '<p><label for="comment"><strong>Questions / Comments :</strong></label> (<span class="cursor" onclick="document.getElementById('comment\').rows += 5;" title="Increase The Textarea">increase</span>  <span class="cursor" onclick="document.getElementById('comment').rows -= 5;" title="Decrease The Textarea">decrease</span>)<br />'."n"
    You didn't escape your single quotes... Try this:
    PHP Code:
    echo '<p><label for="comment"><strong>Questions / Comments :</strong></label> (<span class="cursor" onclick="document.getElementById(\'comment\').rows += 5;" title="Increase The Textarea">increase</span>  <span class="cursor" onclick="document.getElementById(\'comment\').rows -= 5;" title="Decrease The Textarea">decrease</span>)<br />'."n"
    In other words, change
    PHP Code:
    'document.getElementById('comment')' 
    to
    PHP Code:
    'document.getElementById(\'comment\')' 
    choosy developers choose gif!
    website | paintings | blog

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    In PHP, you should only need to escape the quotes that you're also using to surround the string, meaning escaping single-quotes in a double-quoted string isn't necessary, nor are double-quotes in a single-quoted string.

    I can't recall if it just ignores the escaping or not.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Hmmm... I'm pretty sure it sees his single quote and thinks it's an ending single quote.
    Because he has unescaped single quotes in a single quoted string.

    I even uploaded the php file to my server and it got the error, but then when I escaped the single quotes, I didn't get an error anymore.

    So I'm pretty sure you need to escape those single quotes.
    choosy developers choose gif!
    website | paintings | blog

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Trust the syntax highlighting ;-) Those single quotes need escaping :-)

  8. #7
    Member
    Join Date
    Sep 2006
    Posts
    39
    Member #
    13897
    Hi guys,
    thanks for all your advice, i think ive followed all your instructions....but i now get a parsing error on line 123!!!
    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\contact.php on line 123
    I have looked at this line until i was blue in the face, but still can not see what ive done wrong!:disappointed:
    Ive also tried syntax highlighting but its not showing anything up around this section of PHP?
    Ive re-attached my new file! I have missed something or done it wrong? I probably have - sorry to waist your time but i struggle with PHP!!
    AAAAARRRGH!
    Cheers, Edd!

  9. #8
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    You have two problems:
    (1) You forgot to put a space after `echo', so PHP can't tell that it's supposed to be a call to `echo'. Where it says [minicode]echo"[/minicode], change it to [minicode]echo "[/minicode].
    (2) You were too eager in putting the lines together. You can't use `.' inside these, unless you close the double quotes:
    PHP Code:
    echo"
    <fieldset><legend>Contact Form</legend>\n
    <form action='thank_you.php' method='post'>\n
    <p><label for='name'><strong>Name :</strong></label><br />\n
    <input type='text' name='name' id='name' tabindex='1' size='40' value='.
    $_SESSION['name'].' /></p>\n
    "

    Should be:
    PHP Code:
    echo "
    <fieldset><legend>Contact Form</legend>\n
    <form action='thank_you.php' method='post'>\n
    <p><label for='name'><strong>Name :</strong></label><br />\n
    <input type='text' name='name' id='name' tabindex='1' size='40' value='" 
    $_SESSION['name'] . "' /></p>\n
    "

    -OR-
    PHP Code:
    echo "
    <fieldset><legend>Contact Form</legend>\n
    <form action='thank_you.php' method='post'>\n
    <p><label for='name'><strong>Name :</strong></label><br />\n
    <input type='text' name='name' id='name' tabindex='1' size='40' value='
    {$_SESSION['name']}' /></p>\n
    "


  10. #9
    Member
    Join Date
    Sep 2006
    Posts
    39
    Member #
    13897
    Hey Shadowfiend, thanks for that bit of advice. ive made those amends and hey presto my page shows up properly!
    Unfortunately i now have a problem with my thank_you.php file on line 14.
    I have attached all of my php files for this form. If anyone can look at these i would be really grateful - i hope no one thinks im taking the pee with all these requestes. I understand if none of you get time to look at this!
    Or can anyone recommend a GOOD tutorial site for PHP forms??
    (I wish i could remeber where i got the original turorial from - i dont know if id recomend! Im pretty certain i followed it to the letter! Then again i may have completely miss understood the instructions!)
    THANKS! Edd.

  11. #10
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Replace

    PHP Code:
    $Company Name 
    With

    PHP Code:
    $Company_Name 
    or
    PHP Code:
    $CompanyName 
    or whatever you want, as long as there's no spaces :bandit:
    choosy developers choose gif!
    website | paintings | blog


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:10 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com