PDA

View Full Version : quotes printing normally...


Jabbamonkey
10-25-2002, 08:51 PM
Ok, an entry in one of my tables ($title, when called to the page) reads:
The "Cluster" is Alive
Well, when I print this title in a form...
echo"<input type=\"text\" name=\"news_title\" maxlength=\"250\" size=\"30\" value=\"$title\">";
... the form only prints the value "The"
Everything after the quote is erased. The page is actually printing....
<input type="text" name="title" maxlength="250" size="30" value="The "Cluster" is Alive">
The two sets of quotes in the input tag are screwing everything up. How do I make it so the quotes are printed normally?

And, if I'm submitting a value (with quotes), that will be added to a mySQL database, what do I use on the variable before adding it? Do I need to add slashes before submitting it?


Jabbamonkey

mordred
10-25-2002, 09:08 PM
Originally posted by Jabbamonkey
The two sets of quotes in the input tag are screwing everything up. How do I make it so the quotes are printed normally?


You could try htmlentities():


echo "<input type=\"text\" name=\"news_title\" maxlength=\"250\" size=\"30\" value=\"" . htmlentities($title, ENT_QUOTES) . "\">";


Of course, you could also use single quotes to delimit your value attribute.


And, if I'm submitting a value (with quotes), that will be added to a mySQL database, what do I use on the variable before adding it? Do I need to add slashes before submitting it?


Using addslashes() to prevent malicious content is a very good idea.

Jabbamonkey
10-25-2002, 11:10 PM
Cool. Works great. Thanks alot.

Jabbamonkey