yshua Posted August 21, 2012 Share Posted August 21, 2012 Dear forum people: Have PHP5.3.8, MySQL5.5, Apache2.2, Win7 up and running. Have spent a lot of time trying to unravel how to take PHP file customer entries into MySQL database by using elaborate coding and working backwards. Would just like to see some bare bones coding of the simplest of table database statements set up in MySQL, if charset-utf-8 needs to be specified. And a simple Html turning to php file, which in turn allows for a customer input, turning straight to a mysqli data insert. All of that would need an appropriate handling of charset-utf-8. The simplest of examples will work, and I will expand it and modify it till the coding I was already given finally works. Again, unsure if any table database statements specifying charset-utf-8 would even be needed.... Thanks, Yshua :-\ Link to comment https://forums.phpfreaks.com/topic/267359-need-bare-bones-sample-code-of-charset-utf-8-mysqli-handling/ Share on other sites More sharing options...
Christian F. Posted August 21, 2012 Share Posted August 21, 2012 When creating the tables: CREATE TABLE (....) DEFAULT CHARSET=utf-8; Ensuring the correct HTTP header is sent: header ("content-type: text/html; charset=utf-8"); Setting up the MySQL connection: $db = new mysqli (); $db->set_charset ('utf8'); If the tables are created without the proper charset, you can always use ALTER TABLE to correct that. I recommend using phpMyAdmin to help you do that, as it helps simplify the job. If you need to do string manipulation, then you'll want to use the multibyte string functions. For any Regular Expressions you might have you'll want to expand then to use /pL instead of \w, plus adding the 'u' flag, to make them compatible with all legal nationalized letters. Link to comment https://forums.phpfreaks.com/topic/267359-need-bare-bones-sample-code-of-charset-utf-8-mysqli-handling/#findComment-1371044 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.