Reputation: 3124
I am inserting data in mysql table , prior to that i am escape sequencing variable
$data = mysqli_real_escape_string($con,$data);
Every thing is working fine , but when i am getting data like this
$data = " SHR′ n(X′) ";
its escaping data like this
SHR′ n(X′)
which is not inserting in database and giveing error, So my question is how can i make it to escape this kind of characters.
Note:I have created a table with utf8_general_ci
as collation.
Thanks
Upvotes: 1
Views: 87
Reputation: 6079
Try to set the charset to utf8.
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
/* change character set to utf8 */
if (!$mysqli->set_charset("utf8")) {
printf("Error loading character set utf8: %s\n", $mysqli->error);
} else {
printf("Current character set: %s\n", $mysqli->character_set_name());
}
Upvotes: 1
Reputation: 3417
Try this
after establish connection use
mysqli_set_charset ($con, "utf8");
Upvotes: 1