Welcome Guest, Not a member yet? Register   Sign In
Special Character Problem
#1

[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?????????????
#2

[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).
#3

[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??
#4

[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).
#5

[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
#6

[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.




Theme © iAndrew 2016 - Forum software by © MyBB