Results 1 to 5 of 5

Thread: Echo $_POST

  1. #1
    Join Date
    Nov 2007
    Posts
    8

    Unanswered: Echo $_POST

    Hi all, I seem to be having trouble with the echo command, I have never programmed in PHP and am starting to learn!

    What I want to do is write the following:

    Hello Mark, is your date of birth 05/07/1977 correct?

    The php code as follows:

    echo "Hello " & $_POST["fname"] & ", is your date of birth " & $_POST["age"] & " correct?"

    I get this error:

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Code:
    echo "Hello " . $_POST["fname"] . ", is your date of birth " .
          $_POST["age"] . " correct?";
    Shouldn't the age variable be called dob?
    The format of your dates is also unusual for PHP.

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Is the issue got something to do with the fact that you're concatenating a date (or number) to a string..?
    If you remove the age (/dob) value, does it work?
    George
    Home | Blog

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    " & ' have a special meaning in PHP (forget where I saw that)
    also the string concatenation character is the full stop "."
    I'd try

    Code:
    echo "Hello ".$_POST['fname'].", is your date of birth ".$_POST['age']." correct?"
    PHP string concatenation
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Nov 2007
    Posts
    8
    Hi,

    Thank you very much for your help.

    I find the smallest things that throw you out after coming from a microsoft world to PHP.

    I wonder what other simple but complicated things I will find along my PHP journey!

    Date was just an example, thanks so much for your reply. It works a charm.

Posting Permissions

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