Problems with unicode in forms |
[eluser]XploD[/eluser]
Hello. I'm new to CodeIgniter and a PHP newbie. I started following the tutorial in guide and I'm already facing problems with it. I created the form for news in tutorial and unicode characters (like čšćđ) doesn't work. When I echo them in HTML, they work (I'm using Code: <meta http-equiv="Content-Type" c charset=UTF-8" /> Furthermore, the function for generating slug from title deletes that characters. For example, my title is "Testč" and the generated slug is "test" but I want it to be "testc" so č goes to c, ć to c, đ to d, š to s etc. Please help.
[eluser]ortwin.van.vessem[/eluser]
Make sure your HTML content has: Code: <meta http-equiv="Content-Type" c charset=UTF-8" /> The problem mostly with your database collation, you must make it utf-8 since your Code: $db['default']['dbcollat'] = 'utf8_general_ci'; is not the same as your database collation. Change it to: Code: $config['charset'] = "UTF-8"; Config database: Code: $db['default']['char_set'] = "utf8";
[eluser]XploD[/eluser]
I tried unicode and general and none of them works. So, currently I set my database and all tables to utf8_general_ci, I have this in database.php Code: $db['default']['char_set'] = 'utf8'; In my config.php I have: Code: $config['charset'] = 'UTF-8'; The view where the form is has: Code: <meta http-equiv="Content-Type" c charset=utf-8" /> This is the start of the form: Code: <form acti method="post" accept-charset="utf-8" class="stdform" id="registration_form" name="registration_form"> This is my model: Code: <?php This is my controller: Code: <?php And my success view currently displays only text (no HTML at all). Please help, I don't know what to do anymore And I tried all that with utf_unicode_ci as well but it didn't work.
[eluser]InsiteFX[/eluser]
Code: // HTML 4.01: <meta http-equiv="content-type" content="text/html; charset=UTF-8">
[eluser]XploD[/eluser]
Tried both of them, none doesn't work. I tried to play with both utf8_unicode_ci and utf8_general_ci and no success. The problem is definitely in the database because I tried to echo data from form in my success view and it works: https://www.dropbox.com/s/tjzd7i6b92mrtn...161841.png But then again I looked into database and it's like this: https://www.dropbox.com/s/noygd74i21bn96...161904.png This is my database: https://www.dropbox.com/s/1g32rxbnl451xm...161941.png My database.php https://www.dropbox.com/s/6jncvjva5db4ot...162026.png My config:php https://www.dropbox.com/s/za6fwacsz5yosl...162059.png View which contains form: https://www.dropbox.com/s/orvi4w50au842t...162204.png My model for adding data to database: https://www.dropbox.com/s/tk4k1qr84101x0...162507.png I tried EVERYTHING and don't know what to do. This Code Igniter is starting to frustrate me and I'm considering an idea to write my page by myself, without framework. I never had this problem when I was working without framework; unicode characters worked everytime.
[eluser]InsiteFX[/eluser]
Did you create your database with utf8_unicode_ci Collate? Also in your form validation rules you have bcrypt that is an invalid form validation rule. I am not going to copy and paste links, if you want to post links use the Post Reply its a full editor.
[eluser]XploD[/eluser]
No, I didn't select anything while I was creating the database. I edited that in phpMyAdmin later. Because, before using CodeIgniter, when I was writing from scratch, I always just created the database, connected to it and unicode characters worked. I will try to create another database from scratch with utf8_unicode_ci. Links are not my fault. It's a forum protection against spam and bots (I received an error when I tried to insert a link). I'm sorry but there's no other way than copy/paste links. I can create a blank HTML file on my website with links if you want.
[eluser]XploD[/eluser]
I solved the problem. So sorry for bothering you, I was so stupid and I hate this phpMyAdmin. I didn't know that every field in a table has it's own collation. My database and tables were in utf8_unicode_ci but fields in that table were in utf8_swedish_ci. Sorry once again and thank you a lot!
[eluser]InsiteFX[/eluser]
In the future you can make sure the Collation is correct by doing the below. Code: -- ---------------------------------------------- |
Welcome Guest, Not a member yet? Register Sign In |