473,756 Members | 9,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("UP DATE ..."). 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 4018
..oO(webmasterA Tflymagnetic.co m)
>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 htmlspecialchar s() before the output? Without that the browser
would get the "&lt;" and interpret it, so you would get a literal "<".
With htmlspecialchar s() 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***@addr ess.com&\gt;<br />

I've not used any htmlspecialchar s() 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
webmasterATflym agnetic.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
6007
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 cdata sections will be echoed an not the element names as in the original example. In the cdata sections of my XML file I have terms like this:
4
9653
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 href="#"&gt;text&lt;/a&gt;
12
9472
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 element. That did not parse. Here is my question: How can I get attribute values to not get converted from &apos; to '
4
62111
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 supposed to write this function? String.replace(/</g,'&lt;');
3
2561
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 parse this in Xerces and I can see it has done the correct thing,
1
5457
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> <EmployeeStrength>> 1000</EmployeeStrength> When I do a Xmltextreader.read() and then check the contents of the xml node by XmltextReader.ReadString(), I get an exception when I have
1
2711
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> <EmployeeStrength>> 1000</EmployeeStrength> When I do a Xmltextreader.read() and then check the contents of the xml node by XmltextReader.ReadString(), I get an exception when I have
6
24357
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 XSLT and replace all occurances of &lt; with < and &gt; with >.
4
11950
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> </myXml> I there a way that the XSLT transformation can render the content as html rather than text?
0
9292
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10062
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9878
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8733
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7282
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6551
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5322
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2694
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.