While trying to figure out possible reason for the error, the reason seems to be encoding some where in my web app. The strings look fine when I checked them by using var_dump
but upon insertion into the database, I see this characters in my table. I am using PDO for executing SQL queries.
var_dump($string); // the string looks fine here ex- Shopaholics’
// function to create db connection
function db_connect() {
if(self::$db_con === null) {
$db = self::$databases[self::$use_db];
self::$db_con = new mysqli($db['hostname'], $db['username'], $db['password'], $db['database']);
self::$db_con->set_charset('utf8');
}
return self::$db_con;
}
// code to insert into Db
$con = db_connect();
$stmt = $con->prepare(INSERT INTO case_study (case_id, description_case)
VALUES (NULL, :description));
$stmt->bindParam(:description, $description);
$stmt->execute();