If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Echo $_POST

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-31-09, 20:34
ByteLogic ByteLogic is offline
Registered User
 
Join Date: Nov 2007
Posts: 8
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
Reply With Quote
  #2 (permalink)  
Old 04-01-09, 11:20
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
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.
Reply With Quote
  #3 (permalink)  
Old 04-01-09, 11:38
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #4 (permalink)  
Old 04-01-09, 14:16
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
" & ' 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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #5 (permalink)  
Old 04-01-09, 14:54
ByteLogic ByteLogic is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On