Jump to content

[SOLVED] htmlentities/apostrophe trouble


galvin

Recommended Posts

I have a MySQL database with an "item" column and in there is an item for "Sweet Child o' Mine" (because when I submitted it to the database, I entered it into my form as just "Sweet Child o' Mine" and then ran htmlentities on it before placing it in the database).

 

Now I have some code that pulls all the "items" from the database and it pulls it back as "Sweet Child o' Mine" which is causing problems with other code throughout my website that uses this item, but is expecting it to be just "Sweet Child o' Mine".

 

NOTE: I have plenty of other "items" that do NOT have apostrophes and they are working just fine.

 

Below is the basic code where, after I queried the items from the MySQL database, I tried to use html_entity_decode to turn it back to just "Sweet Child o' Mine" but it's not doing it.  It still has it showing as "Sweet Child o' Mine" when I echo the $output variable.

 

Any ideas what I'm doing wrong?

 

while ($row = mysql_fetch_assoc($result)) {

     $output .= '"' . html_entity_decode($row['item']) . '",';
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/161287-solved-htmlentitiesapostrophe-trouble/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.