Click here to Skip to main content
15,906,558 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My problem is very interesting
I have some data stored in database
as text like
I & YOU
THEY & HE
AMERICA & INDIA

as Single Text
when I am fetching the data
and showing the same in
page
its getting trimmed after the "&"
Am getting I ,THEY,AMERICA
and so on .

This Must be due to the syntax matching with  .
How can I solve this issue.

[edit]HTML encode added - OriginalGriff[/edit]
Posted
Updated 15-Oct-12 0:29am
v2
Comments
project virus 15-Oct-12 6:20am    
which another language u r using..please discuss dis Que. briefly.
Karwa_Vivek 15-Oct-12 6:49am    
Actually I am Fetching the Database Values
and storing the same in a String
and then passing the string to other page using a link reference
and then showing the value in other page .I am using SQL Database. and VB.net

Vivek,

Are you sure the data is stored in the database as you are showing. Actually if your database column is varchar, then you have to save as & for it to store correctly and retrieve.

Just write select * from table in SSMS (if using SQL) and check.
-Milind
 
Share this answer
 
Ampersand is a special character in HTML - it introduces a sequence so that "&lt;" for example, is shown as a "<", and "&gt;" as a > - otherwise your text would be processed as a tag by the browser.

Depending on what language you used to store the strings, you could (and should) HTML encode them before you store them - otherwise your site could well be vulnerable to an HTML Injection attack, as well as displaying the data incorrectly.

You don't say what you use, so we can't suggest anything!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900