ilhan
ilhan

Reputation: 8985

Reading UTF-8 data from MySQL shows ? instead of ı

Here is how I read the data:

<?php
$id = $_GET["id"];
$number = mysql_real_escape_string($id);
$result = mysql_query('SELECT * FROM `mystory` where `id` = ' . "$number" . ' LIMIT 1');

$row = mysql_fetch_assoc($result);
echo $row['story'];
?>

The data is encoded as utf8_bin. Insted of ı PHP outputs ?

Why is that?

Upvotes: 4

Views: 964

Answers (3)

Salem
Salem

Reputation: 774

This is the only code worked for me :-

mysqli_set_charset($con,'utf8');

Where $con is your connection value to DB . Be sure put the code after connect and error code and you will be fine .

Upvotes: 2

Alex Pliutau
Alex Pliutau

Reputation: 21957

I am use all this operations:

mysql_query ('SET NAMES utf8');
mysql_query ('SET CHARACTER utf8');
mysql_set_charset ('utf8', $LINK);

Upvotes: 0

Daniel Egeberg
Daniel Egeberg

Reputation: 8382

You need to make sure that your connection to the database us in UTF-8 as well. You can do that this way:

mysql_query("SET NAMES utf8");

Also make sure that you are telling the browser that it is UTF-8:

header("Content-type: text/html; charset=utf-8");

Upvotes: 13

Related Questions