This is really weird to explain, so here it goes...
I'm fetching data from phpmyadmin that contains unescaped single quotes. I'm trying to convert '
to '
by using Content-Type: text/html;
in a php header.
In one column of the database, this is the value: This year's...
I set the content type to <?php header('Content-Type: text/html; charset=UTF-8'); ?>
I fetched the data with mysql_fetch_assoc()
, so it should output, This year's
. But, it outputs This year�s...
.
I then manually deleted This year's...
from the database and replaced it with the same This year's...
(directly in the database). I set the content type to text/html
again and got this:
This year's...
That's it... this is almost imossible to explain. A single quote is submitted to the database through a form. I fetch it and set the content type to text/html and it outputs '
as �
. If I go into the database, manually delete the '
, and replace it with the same '
, it then outputs '
.
Has anyone ever experienced this weird quirk or recognize what it might be?
UPDATE:
The value in the database is This year's
which was uploaded by a form. The quote is unescaped in the database. Here's how I'm fetching the data. I want the '
to be converted to '
.
<?php
header('Content-Type: text/html; charset=UTF-8');
include('init.inc.php');
function get_feeds() {
$query = mysql_query("SELECT * FROM test ORDER BY id DESC LIMIT 1");
while($fetch = mysql_fetch_assoc($query)) {
$text = $fetch['text'];
echo $text;
}
}
?>
<?php get_feeds(); ?>
It outputs This year�s
.
I then delete This year's
from the database and manually write This year's
in it's place. It outputs this This year's
.