views:

71

answers:

2

I'm a complete mySQL & PHP noob, and in my table, whenever there is an apostrophe, it gets replaced by ’. I've searched and found that it could be because my table is not UTF-8, but I changed all the collation settings in phpMyAdmin to utf8_unicode_ci, and I still get the ’.

To be clear, I am sending the data to a PHP script from an iPhone app using NSURLConnection. In the url it loads, the apostrophe is replaced by %E2%80%99. My server is running Linux.

Thanks for any help guys!

+4  A: 

You have to make a query before storing data:

SET NAMES utf8.

Apparently it's mysql_set_charset('utf8',$conn) in 5.2+

meder
Right. I will upvote if you mention the PHP function for that. Using a `SET NAMES` query is considered deprecated in PHP world :)
BalusC
Meh, I never keep up with php. Is the edit it? :p
meder
That worked. Thanks for the quick response!
Brian515
A: 

The apostrophe gets urlencoded. You will have to decode it using urldecode on the php side, then put it into the database.

Femaref
PHP will by default already url-decode it.
BalusC