PDA

View Full Version : HTML with MySQL > and <


jonathan7799
02-04-2005, 04:11 PM
Hi,

My trouble is this.

I have a Perl script accessing a MySQL database that contains a veriety of things as well as HTML content.

My Perl creates an interface for editing the HTML content, everything is find up until I add &lt; or &gt; which is part of the content and not part of the html, what it does during edit is display the &gt; as < rather than just leave it alone as I would like...Also, the content is written in HTML, so it must leave alone < and > as they are, as well as &gt; and &lt; without conversion.

Then when the edit is complete and the content displayed it thinks that whats held between the <> is html code and doesn't display it....

I realise that it is the browser thats doing this, but surely there is a way to either stop it or protect the symbols...

Can anyone help with this.....

Jonathan

P.S. Incidentally, I notice that this system doesn't have this problem, though I do not wish to move to PHP at this point....

Horus Kol
02-04-2005, 04:17 PM
if you had &amp;gt; that will fix it...

i guess that & is replaced by &amp; when it is entered into the database here at coding forums...

jonathan7799
02-04-2005, 04:22 PM
I tried &amp;gt; ...

It goes through the edit once, but on second edit it is converted goes like this...

&amp;gt; then &gt; then >

am I missing something in the Perl...

Jonathan

Horus Kol
02-04-2005, 04:46 PM
ah...

right...


when you submit the form, and before it gets entered into the database, you need to replace any & symbols with &amp;

that way, when it is displayed again it will only look like &, but will again be entered into the database as &amp;