Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
October 13, 2006, 12:16 pm
rate this thread
I have been getting strange behaviour when using ' in by textboxes.
eg inputting the following
this is some test text ' and so is this
is saved to the mysql database ok as
this is some test text /' and so is this (with add slashes)
this is some test text ' and so is this (without add slashes)
mysql field is VARCHAR(255)
but when I retreive the data and display in textboxes on my web page, text
area type (below) is ok
<textarea class='BodyText' style='WIDTH: 85%' name="textarea"><?php echo
but input type (below) cuts everything off after the ' character. However
this does not happen with other characters such as " or /
<input type='text' class='BodyText' style='WIDTH: 85%' name='test'
value='<?php echo $opta; ?>'>
can anyone explain this behaviour and have a solution so that text with any
' characters in it is fully displayed?
Re: everything after ' character is not displayed
Which is exactly as is should be. The ' in the text means it's the end of
the value. I't invalid HTML, and most browsers will handle the 'extra'
attributes (that's what it is after the ') by discarding it.
htmlspecialchars() or htmlentities() your $opta.