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
Try this
after establish connection use
mysqli_set_charset ($con, "utf8");
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());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.