Log in

View Full Version : How to insert <text> into a text field



IRG
09-16-2008, 08:28 AM
I need to insert the following text into mysql db: <text1>.<text2>. When I run a statement insert into table(field1) values ('<text1>.<text2>') the output is .. .. If I run a statement insert into table(field1) values ('<<text1>>.<<text2>>') the output is <><>. The statement insert into table(field1) values ('\<text1\>.\<text2\>') produced .. .. result.
Please help!!!!!!

motormichael12
09-16-2008, 04:31 PM
insert into table(field1) values ('&lt,text1&gt;.&lt;text2&gt;')

To convert text in PHP do it like this:



$var1 = "hey <b>there</b> <span>ted</span>";
$var1 = htmlentities($var1);
echo $var1;


That returns:

hey &lt;b&gt;there&lt;/b&gt; &lt;span&gt;ted&lt;/span&gt;
However when that is placed in HTML it is parsed, so the display on a web page would be EXACTLY as is is set in $var1, with the errors. It will not parse the HTML unless you decode it.

IRG
09-17-2008, 12:18 PM
Thanks a lot, it works beautifully.