Connecting Tech Pros Worldwide Help | Site Map

& not retrieve from Mysql Database

Newbie
 
Join Date: Aug 2009
Posts: 2
#1: Aug 5 '09
Hello friends,

I have face a problem, the problem is that when i fetch data from mysql database i get '&' in the place of '&'. I am using php 5.1.2 and mysql version 5.0.11-beta.

What is the problem? any body solve my problem?

Please answer me.

Thanks in advance!
code green's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,076
#2: Aug 5 '09

re: & not retrieve from Mysql Database


Are you sure?
If viewing results in a browser you won't see the 'amp;'
Newbie
 
Join Date: Aug 2009
Posts: 2
#3: Aug 6 '09

re: & not retrieve from Mysql Database


Thanks for your reply.

Yes i can't see the 'amp;'.

I entered a text like 'testing articles & others' in a text box. This text saved in a mysql database like 'testing articles & others'. But when i fetch this text through mysql_fetch_assoc the text display in the browser like 'testing articles & others' and if i submit this text again in the database i find only 'testing articles & others' . So each time when i edit this i have to put '&' in the place of '&'.

Thanks in advance!
code green's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,076
#4: Aug 6 '09

re: & not retrieve from Mysql Database


If you view the browser source code you will see '&' It is still there just not visible in the browser as should be.
But if I understand your problem, you wish to reinsert the edited data back into the DB with 'amp;' still intact.

First just double check what I have said above is correct.
Then are you using PHP by any chance?
If so try calling function htmlspecialchars() just before inserting the text back into the DB.

Failing that, the only thing I can think of is runnng the text through your own function using string functions to add the additional 'amp;' before re-insertion
Reply