Jump to content

[solved] PHP MySQL database wrong character set displaying


lambik

Recommended Posts

http://mysql.ee-p.eu/ that's my MySQL database and I have problem with character sets. Sometimes it displays characters like ľ,š,č,ť,ž,ý,á,í,é,ä,ň,ď properly but it never displays them all properly at once. Can anybody tell me how to change this setting to utf8 slovak set? ThanksEDIT: when i write code on a page, i save it as utf8 coding. When i upload it to database and i press edit in it, it opens up in ancii coding and characters like á are shown as AÄ or something like this. Ive changed setting in my tables to utf8 slovak ci but it doesnt seem to help. Thanks for help
Link to comment
Share on other sites

changing the database and table collation (utf8_slovak_ci) from your phpmyadmin will fix it i think ..not sure though.

Link to comment
Share on other sites

Hey, thanks, but I am newbie to this (just 3 days) and I don't know how to configure this. Only thing I got is when I create a new table I always set character set to utf8_slovak_ci to varchar arrays, but this doesn't solve the problem.

Link to comment
Share on other sites

In addition to setting the database collation, upon connecting to the database, you must use mysql_set_charset() to set UTF-8 as your charset.You must also add an appropriate content type header, or to be more precise:

header('Content-Type: text/html;charset=UTF-8');

and you should also make sure your PHP file is encoded as UTF-8 (in Notepad, in the "Save As..." dialog, look at the "Encoding" drop down menu).

Link to comment
Share on other sites

Still actual...EDIT: Ok so my beatiful code now looks like this:

<?php$ip=@$REMOTE_ADDR;header('Content-Type: text/html;charset=UTF-8');$spojenie=mysql_connect("localhost", "menus_ee-p_eu", "52624513");if (!$spojenie) {	die("Chyba pri pripájaní k databáze.");}$db=mysql_select_db("menus_ee-p_eu", $spojenie);if (!$db) {	die("Chyba pri výbere databázy.");}$sql	  = "SELECT * FROM komentare WHERE autor='$_REQUEST[autor]' && nadpis='$_REQUEST[nadpis]' && kam='$_REQUEST[kam]' ORDER BY ID DESC";$vysledok2 = mysql_query($sql);$sql2	 = "SELECT * FROM komentare WHERE autor='$_REQUEST[autor]' && nadpis='$_REQUEST[nadpis]' && kam='$_REQUEST[kam]' ORDER BY ID DESC";$vysledok = mysql_query($sql2);?>

Let's see if this is gonna work.

Link to comment
Share on other sites

Nobody who can help me?EDIT: I tried everything as you suggested me above, yet nothing has worked for me...at least I just found out how to get my ftp server show me that symbols right (ľ,š,č,ť,ž,ý,á,...) but the problem lays in the database, dont know where. I set collation of tables to utf8_slovak_ci, tried unicode, same result,... but whats interesting is, it shows me properly á,ý,í,é,ä even if it has saved them to table as ˇA" or something like that...but when it saves č as ˇA? it is not shown properly. Damn.EDIT2: Now, it is working properly. I must switched table collation to latin2_czech_cs case-sensitive type and it is somehow working now. Czech language isnt so different from Slovak so I suppose it wont cause problems anymore. :)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...