Problem getting info from form (PHP)

Associate
Joined
2 Aug 2005
Posts
680
Hi,

I've created a form with various text and radio fields, however PHP is throwing an error when I am trying to put the info into an email:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING on line 88

and line 88 reads:

Code:
$subject = 'L&D booking request from ' . "$_POST['name']" . ' (' . "$_POST['email']" . ')';

Any help would be appreciated.

Thanks,
 
No, it's the array indice as string that causes this problem ($var['foo'] - the 'foo' bit)

Other ways around it are:

Code:
$string = "bar $var[foo] bar";
$string = "bar {$var['foo']} bar";
$string = 'boo ' . $var['foo'] . ' bar';
 
I see what you mean :)
The only trouble I'm having now is with line breaks. I've added them in like this
Code:
 "\n" .'Work address in full, including postcode: ' . $_POST['address'] 
			. "\n" .'External telephone number: ' . $_POST['exttel'] 
			. "\n" .'Internal telephone number: ' . $_POST['inttel'] 
			. "\n" .'Mobile number: ' . $_POST['mobtel'] 
			. "\n" .'Email address: ' . $_POST['email']

But it's just coming out in a string of text like this
Work address in full, including postcode: address 1 address 2 External telephone number: 2 Internal telephone number: 2 Mobile number: 2 Email address:

Outlook says it has removed extra line breaks and if I click where it says it can put the line breaks back. Do you know any way of getting around this?
 
Just tried that but it's still doing it. It only seems to be missing the line break if something in the form has spaces in (like the address for example). If the field has no spaces it's leaving the line break.
 
Actually scrap that, it's doing it randomly (some of the fields with spaces have line breaks and some without don't have breaks). Any ideas?
 
Last edited:
Back
Top Bottom