Insert French Characters Into MySQL

June 4, 2010 | PHP | , , , ,

I was developing a bi-lingual website, so my custom CMS should be able to accept and display both English and non English characters. For English characters, it’s a piece of cake. But for French characters, I have pulling my hair for days to find out what went wrong with my script.

I have set the database to use UTF-8 encoding, but every time I inserted the text it’s messed up. French characters become a horror, unreadable for everyone.

After several days –literally– I have found the solution: I must set the character set into UTF-8 right before I insert the data!

< ?php
mysql_query("SET CHARACTER SET utf8"); //<--the key!
mysql_query("insert into data values ('$french_chars')");
?>

SET CHARACTER SET utf8 will tell MySQL to store the inserted data using UTF-8 encoding. And it works for me.

4 comments


Download Youtube with PHP and CURL

April 15, 2008 | PHP | , , ,

This is an update for my previous Youtube Downloader.

If you don’t know what is PHP Youtube Downloader, it is a simple PHP script that we can use to download video from Youtube.com. You must, at least, having PHP installed and CURL activated.

Download the source at here and read some information at Google Code Page.

Have fun!

6 comments