This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 9 years ago.
In my mysql database i have string with german umlauts (ä, ö, ü).
I query them with php/mysql and when displayed on my website, they show up like this:
�
I have this html in my website:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
edit: i have changed all collations to utf8_unicode_ci but the problem still persists
If you have written html meta tag as charset=UTF-8 and you have set Collation as utf8_unicode_ci character set and its not working then you must use
mysql_set_charset('utf8');
use this where you have made your connection file, like this:-
$link = mysql_connect("localhost","root","");
$db = mysql_select_db('testing');
mysql_set_charset('utf8');
Related
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 3 years ago.
im not new in php coding and have a problem. I need insert data to sql (czech language encoding).
I wanna input this string: +ěščřžýáíéůú
My DB output is: +ì¹èø¾ýáíéùú
So, im trying this solutions:
1) My config.php has this one:
header('Content-Type: text/html; charset=utf-8');
ini_set("default_charset", 'utf-8');
2) On top of the page is this meta-tags:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta charset="utf-8" />
3) When im connecting into db, im using:
#define("DB_Connect_Charset", "utf8");
$dsn = 'mysql:dbname='.DB_Connect_Database.';host='.DB_Connect_Hostname.';charset='.DB_Connect_Charset;
+
$this->pdo = new PDO($dsn, DB_Connect_Username, DB_Connect_Password, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES ".DB_Connect_Charset));
Im trying some php functions like: iconv OR mb_convert_encode()
Database has utf8_czech_ci coding, when im trying to change it into windows-1251 or latin.. it doesnt help.
I spend a lot of time on stackoverflow and cannot find a solution about this problem, some problems will be deleted with SET NAMES UTF8.
Problem must be in part when im sending data to SQL, because if im put data manually into sql, im fetching it correctly.
Thank you for your time and help. Have a nice day!
When I'm binding parameters I use utf8_encode function for value. It was a mistake.
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 4 years ago.
I have a data in my mysql database's table which is Biñan. However, when I try to retrieve it using php, it showed as Bi�an in my dropdown list.
Here is my sample code:
<?php
$query = "SELECT * from municipality";
$res = mysqli_query($conn,$query);
while($row = mysqli_fetch_assoc($res))
{
echo "<option value='".$row['m_id']."'>".$row['m_name']."</option>";
}
?>
But when I manually echo/insert the character ñ in php/mysql it displayed as is. I have also set the charset to UTF-8.
PROBLEM SOLVED!: I just have to replace the ñ with ñ in my database's table. So it shows ñ in my website.
add this in your head html file.
in a balise:
meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
Try to:
ALTER DATABASE <databasename> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE municipality CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
otherwise it's in the database.
do this in your database.
ALTER TABLE municipality COLLATE utf8_general_ci
or
ALTER TABLE municipality CONVERT TO CHARACTER SET utf8;
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 8 years ago.
All danish characters (æøå etc.) are replaced by questionmarks on my page. It's a classic
Everything (host, database, table) is set to utf8_unicode_ci in phpmyadmin
Every column in the table is set to utf8_unicode_ci
My webpage file is made and saved in UTF-8, and has the php header + meta:
header('Content-type: text/html; charset=utf-8');
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Then I run a mysql charset test in php:
var_dump($conn->get_charset());
The result?
["charset"]=> string(6) "latin1" ["collation"]=> string(17) "latin1_swedish_ci"..
(trimmed vardump)
Why? And how can I fix this?
You have to execute this query after connecting to mysql:
SET NAMES 'utf8'
i have a webpage which is based on Smarty 3.3.2 and my webhoster networksolution.com upgraded my php version to the PHP Version 5.4.17-pl0-gentoo and all my arabic characters (database latin1 (tried to utf8 - no results)) are shown like:
®Ù¾Ù„ §Ø±Ù¾®Ù¾Ù„ اØØ؇ ساØ
This is the format like my database inserts but the mainly problem is that before my server was updated (it was 5.2.) it worked correctly, my header is already set up to utf-8
My template is shown correctly, so the problem is with the mysql_query!
Thanks!
First of all please confirm that the arabic text is saving correctly in the database, if it is ok then just add following code just before your select query
mysql_query("set characer set utf8");
and add
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
this code
and if arabic text is not correctly saved in database then please change your database collation to UTF-8.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
UTF-8 all the way through
I'm developing some new features on a website that somebody else already developed.
I'm having a problem the charset.
I saw that the database had some tables in utf8 and some in latin1
So I'm trying to convert all the tables in UTF8.
I did it for one table (also the fields of this table now are utf8), but was not successful.
I'm using the normal mysql connect. I have to put any config to say that it must connect with utf8 to the DB? If yes witch one?
In my html I have:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
It looks like some letters works and others display the question mark.
For example it not able to display this ’ that is different of this: '
Try this
<?php
header('Content-Type: text/html; charset=utf-8');
?>
and then in the connection
<?php
$dbLink = mysql_connect($argHost, $argUsername, $argPassword);
mysql_query("SET character_set_results=utf8", $dbLink);
mb_language('uni');
mb_internal_encoding('UTF-8');
mysql_select_db($argDB, $dbLink);
mysql_query("set names 'utf8'",$dbLink);
?>