Ok, I have been searching everywhere for solutions for charset problems I have.
I have php website and backend Mysql database. In some fields I need to put in letters from the Greek alphabet.
If I use a form to send info to the database and type in Greek letters, and then extract it from the database and splash on the screen in the browser, then it looks fine, the greek letters show up all correctly. But if I go and take a look at the database for example in phpmyadmin, where the greek letters are supposed to be, then it just returns some jibberish. with question marks, arrows pointing up and stuff like that. This is a problem since I need to be able to export the database to an excel file, and there it returns the same jibberish as in the database.
Im going to show you some of the variables in phpmyadmin and an example of how I would create the database and tables with charsets and collation.
The database i would make somehow like this:
CREATE DATABASE `database1` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Table I would make like this:
create table table1(
id_number int(5) primary key auto_increment,
amount int(7) NOT NULL,
owner int(1) NOT NULL,
category char(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
description varchar(70) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
date date NOT NULL
)type=innodb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Here I make collate latin1_swedish_ci collate on some columns just to save space(since this will only include letters like A, B and so on).
variables in phpmyadmin:
character set client utf8
(Global value) latin1
character set connection utf8
(Global value) latin1
character set database latin1
character set filesystem binary
character set results utf8
(Global value) latin1
character set server latin1
character set system utf8
character sets dir C:\xampp\mysql\share\charsets\
collation connection utf8_general_ci
(Global value) latin1_swedish_ci
collation database latin1_swedish_ci
collation server latin1_swedish_ci
When I go to php, connect to the database and check the connection it says latin1.
For example:
$db = new mysqli('localhost','user','password','database1');
$charset = $db->character_set_name();
echo "<br />Charset of connection is: ".$charset."<br />";
this would echo latin1.
In the header of the html file I have UTF-8.
I also tried to change some apache charset settings for example in iconv and so on. but nothing worked. I also put in a php header at the top of the document with something like this header('Content-Type: text/html; charset=utf-8'). I also included UTF-8 inside the form tags.
What do I need to do here, this is driving me crazy. Please help.