frequently ask ? : Computers : Programming : Languages : PHP : kms : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 17 people (76%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Why is a single quote and everything after it being truncated when loaded into a form text box? The other escaped characters are showing up.

Apr 22nd, 2001 18:50
Onno Benschop, Bryan Lawson,


Because the single quote is ending the value declaration from your 
input box. 
   Text:  This isn't cricket
   HTML:  <input type=text name=bob value='This isn't cricket>
   Note that the value declaration ends with the ' between n and t.
You can overcome this by using double quotes for your value declaration 
and using the htmlentities function to encode the variable:
  echo '<input type=text name=bob value="'.htmlentities($bob).'">' ;