Hi i am having some issues with some characters (ë and ç from Albanian). To illustrate i have made a txt file (hi.txt) and in it is written “hehz çadër”. I have this script to read the file and write the content to a DB field:
mysql_select_db('test');
mysql_query("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci'");
$text = mysql_real_escape_string(file_get_contents('hi.txt'));
echo $text . '<br />';
mysql_query("INSERT INTO test (field) VALUES ('$text')");
This echoes “hehz çadër” as intended, but in the database is stored only "hehz ".
What am i doing wrong?
Hmmm. Well it is very weird because as i said i use the same code for all languages and the others work. Anyway i guess i should ask about this in the PHP forum then. Thanks!
then the problem is not the table/mysql, the problem is your front end application.
Are you using utf8 everywhere, including the database tables?
Have you tried inserting the values directly in the database table? If they insert fine then the problem could be PHP related.
Hi, sorry for taking so long, i was on vacation.
I can insert the characters directly to the table from phpmyadmin so no problem there. Also i am using utf8_unicode_ci as the table collation.
What’s bugging me is that it’s not even inserting them in any funky form. It just stops inserting all the rest of the text when it finds one of those characters.
What could be wrong?
You are telling us above that you can insert the data into the table fine with phpmyadmin. If that is the case then you are introducing the error in your front end application, whether php, perl, c, java etc. you may see the same error.
This is the info for magic quotes:
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
then the problem is not the table/mysql, the problem is your front end application.
Shouldn’t though be problems with other languages too then?
Is magic quotes disabled on the server?