CodeIgniter Forums
Special Character Problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Special Character Problem (/showthread.php?tid=13508)



Special Character Problem - El Forum - 11-25-2008

[eluser]manash007[/eluser]
How can i handle special character in ajax form submit.....
when i have submitted my form by ajax in that case special characters are not inserted in right way....
any help?????????????


Special Character Problem - El Forum - 11-25-2008

[eluser]uptime[/eluser]
I think we need more info, post the output of the following code:

Code:
var_dump($_GET, $_POST);

Also, what do you mean "not inserted in right way" - are you talking about MySQL?

Maybe you could also show us some of your code (relevant parts).


Special Character Problem - El Forum - 11-25-2008

[eluser]manash007[/eluser]
i am posting as $_POST method in AJAX......
ya i m talking about MySQL.......

$test = htmlspecialchars($_POST['posted_value']); // ex: $test = Ü;
When i am running query.... insert into table(column_name) values("$test");

but it inserts into mysql another value... neither Ü nor Ü

i've also tried without htmlspecialchars. but it wont work.....
how can i fix this??


Special Character Problem - El Forum - 11-25-2008

[eluser]uptime[/eluser]
* Check your query, make sure the insert statement is OK: $this->db->last_query();

* Backup your DB...

* Make sure that your DB / tables are UTF-8 (if not, change them).


Special Character Problem - El Forum - 11-25-2008

[eluser]manash007[/eluser]
all things are fine......
query is obviously ok coz all other column values are inserted correctly which are not in special character.
DB table is also in UTF-8 character-set


Special Character Problem - El Forum - 11-29-2008

[eluser]Natebot[/eluser]
Since you are using Unicode, try
$test = htmlspecialchars($_POST[‘posted_value’], ENT_NOQUOTES , 'UTF-8' );

Assuming your html dictates UTF-8 ( <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> ) and your database is using UTF-8 collation, then my guess it has to do with use PHP functions. Some I understand don't support UTF-8 so well.

I have read that if you do not set the optional $charset parameter in htmlspecialchars you will experience problems and even so there may still be misinterpretation of UTF-8 content.

However, am I understanding the problem corretly? Because the character Ü should not be affected by htmlspecialchars.