473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to prevent HTML code such as &lt; being rewritten as <

Folks,

I'm struggling to put the question together, but I have this problem.
I have written an HTML form that I can use for data entry. This uses
PHP to write a SQL UPDATE command that gets written to my MySQL
database. I can later view this data back in the form.

One thing I've noticed happening is if I enter code such as &lt; it
gets rewritten as < (ie the less-than sign). Now I don't want this to
happen, but something somewhere is converting this. This is annoying
because it messes up my HTML code.

The HTML form calls itself (ie $_SERVER['PHP_SELF']), and then builds
the UPDATE command. It pushes this out to the database using
mysql_query("UPDATE ..."). Is this something that is done by
mysql_query(), because it is clearly being stored on the database as
this.

Is this a feature of mysql_query(), or is there some other way to turn
this off?

Any help will be appreciated.
Feb 7 '08 #1
3 3979
..oO(webmasterATflymagnetic.com)
>Many thanks for this. After I posted I realised I could echo the
output that comes back into the script. And it clearly has already
been modified as soon as it comes back in. So the &lt; rewrite is
happening between the $_SERVER[$PHP_SELF] submission on the form, and
the next time the PHP file is sent back to the browser.
What does a

print "<pre>\n";
var_dump($_POST);
print "</pre>\n";

show after the form submission? The "&lt;" should still be there.

Then how do you show the submitted data again after the submission? Do
you use htmlspecialchars() before the output? Without that the browser
would get the "&lt;" and interpret it, so you would get a literal "<".
With htmlspecialchars() instead the result in the HTML source would be
"&amp;lt;", which would then be interpreted to the intended "&lt;".

Micha
Feb 7 '08 #2
SOLVED IT!! (Why do I always seem to find the answer shortly after
hitting the send button? -- Bummer!)

Anyway, what I've done is this:

<pre>
Return-Path: &\lt;em***@address.com&\gt;<br />

I've not used any htmlspecialchars() calls, and the above gets written
to my database entry exactly as shown. I did originally try \&lt; but
that simply resulted in \< -- so the escape never worked. At least
this way it does work.

So I'm a happy bunny...

tra la la, tra la la...

(if a little mad!)

Thanks all again!
Feb 7 '08 #3
webmasterATflymagnetic.com wrote:
SOLVED IT!! (Why do I always seem to find the answer shortly after
hitting the send button? -- Bummer!)
I just know what`cha sayin` ;-)

--
Freundliche Grüße,
Franz Marksteiner

Feb 7 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: wenke | last post by:
Hi, I am using the following code (see below) from php.net (http://www.php.net/manual/en/ref.xml.php, example 1) to parse an XML file (encoded in UTF-8). I changed the code slightly so that the...
4
by: matatu | last post by:
Hi to all, I have a xml file, a substring like: &lt;a href=&quot;#&quot;&gt;text&lt;/a&gt; which after an xslt trasform is rendered as (using xsl:output method html): &lt;a...
12
by: Sammy | last post by:
Hi, my mind is going crazy. I have tried everything I can think of to no avail. I have tried Disable Output Escaping. I tried to think of a way of enclosing the attribute data in a CDATA...
4
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I...
3
by: shaun roe | last post by:
a follow up with new problems from my previous post: I have xml encoded in a string with elements like &lt;myElement/&gt; e.g <codeFragment> &lt;myElement&gt;some text&lt;/myElement&gt; </codeFragment> I...
1
by: RJN | last post by:
Hi I'm using XMLTextReader to parse the contents of XML. I have issues when the xml content itself has some special characters like & ,> etc. <CompanyName>Johnson & Jhonson</CompanyName>...
1
by: RJN | last post by:
Hi I'm using XMLTextReader to parse the contents of XML. I have issues when the xml content itself has some special characters like & ,> etc. <CompanyName>Johnson & Jhonson</CompanyName>...
6
by: tentstitcher | last post by:
Hi all: I have a source xml document with an element of type string. This element contains something like the following: <stringData> &lt;Header&gt; &lt;Body&gt; </stringData> I would like to apply an...
4
by: mark4asp | last post by:
I have an element, report which contains tags which have been transformed. E.g. <pis &lt;p&gt <myXml> <report>This text has html tags in it.&lt;p&gt which but <has been changed to &lt;&gt</report>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.