> -----Original Message-----
> From: Lso . [mailto:[EMAIL PROTECTED]
> Sent: 25 June 2003 18:32
> 
> ok i see why i didnt work but i dont know why.
> 
> can anyone tell me why this works:
> 
>    <input name="testfield" type="text" value="<? echo 
> htmlentities($company) 
> ?>">
> 
> but this doesn't:
> 
> echo "<input name='company' type='text' value='". 
> htmlentities($company) 
> ."'>";

Because by default htmlentities will convert double quotes but not single ones -- if 
you convert the second one to use double quotes in the HTML (like the first one), it 
should work:

   echo '<input name="company" type="text" value="', htmlentities($company), '">';

Or you could use the optional 2nd parameter to htmlentities to make it convert single 
quotes as well -- the following is a quote from the manual page at 
http://www.php.net/htmlentities:

> the optional second quote_style parameter lets you define what will
> be done with 'single' and "double" quotes. It takes on one of three
> constants with the default being ENT_COMPAT: 
>
> Constant Name   Description 
> ENT_COMPAT      Will convert double-quotes and leave single-quotes
>                 alone. 
> ENT_QUOTES      Will convert both double and single quotes. 
> ENT_NOQUOTES    Will leave both double and single quotes unconverted.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to