Im making an API for a company that inserts orders via this api into our DB, but I'm running into a problem:
Chinese characters don't get stored into my tables, how to fix this?
I have:
- My test file which uses cURL to post set to utf8 via header*
- The API code which inserts the data set to utf8 via header*
- Stored my phpfile as an UTF-8 encoded file
- mysqli connection set to utf8 ($connection->set_charset("utf8")
)
- mysql-database set to utf8_general_ci
- mysql-table set to utf8_general_ci
- mysql-columns set to utf8_general_ci
- I insert the values into a VARCHAR and into a TEXT column (for test purposes)
- Inserted the values directly into the query -> no result
- Inserted the values via iconv("ISO-8859-1","UTF-8", $text)
-> weird result
- Inserted the values via iconv("UTF-8","UTF-8", $text)
-> no result
- Tested characters like áéíúó
, which work perfectly fine
- Set my postvalues for curl via foreach($post as $k=>$v){ $data.= $k.'='.$v;}
to send as data
- Set my postvalues for curl via http_build_query($post)
to send as data
- Used a query before inserted doing SET CHARACTER SET utf8
- Used a query before inserted doing SET NAMES 'utf8'
- When I echo the query before inserting it, I see the chinese characters
- When I check the database, it's blank values
- (not unexpected:) When I Select it and output it, it's blank
*PHP charset header:
header('Content-Type: text/html; charset=utf-8');
I'm out of ideas, anyone?