在尝试找出错误的可能原因时,原因似乎是在我的网络应用中编码某些位置。当我使用var_dump
检查字符串时,字符串看起来很好,但在插入数据库后,我在表格中看到了这些字符。我正在使用PDO执行SQL查询。
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();