RE: [PHP] php mysql apostrophe issue
| From: | John W. Holmes | Date: | Sun, 04 May 2003 16:26:06 +0000 |
| Subject: | RE: [PHP] php mysql apostrophe issue | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146370@lists.php.net to get a copy of this message | ||
> > > Okay, I don't need to replace it, but now when I am getting the
info
> > > from the mysql database that has an apostrophe in it, it just
cut's
> > off
> > > everything from the apostrophe on. For example, I am reading in a
> > field
> > > that contains "I like my dad's haircut." But then I go to output
it,
> > and
> > > it reads, "I like my dad" Any ideas?
> >
> > No, not right off hand. How are you displaying the data? A simple
echo
> > or within a text box? If it's a text box, look at your page source
for
> > the reason why.
>
> It is within a textbox. What do you mean "look at your page source
for
> the reason why?"
Did you do it? Look at the text box where you are trying to display this
value and see if you can spot the problem. FYI: HTML does not recognize
two single quotes or a backslash as escape characters. It only
understand HTML entities. Spoiler below if you can't figure it out...
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
SPOILER:
You have something like this:
<input type='text' name='foo' value='it's my value'>
Do you see the problem in the value? Whether you have the single quote,
two of them, or use a backslash as an escape, you'll end up with the
same. HTML will cut off the value at the first single quote.
To stop this, you must use htmlentities() or htmlspecialchars() on the
data before you place it into the value tag.