#039代替MySQL数据库中的撇号

时间:2019-06-20 12:53:42

标签: php html

我在做$mysqliConnection->query($query);

其中$query...VALUES ("Hellblade: Senua's Sacrifice", now())...

在数据库中就像Hellblade: Senua's Sacrifice

1

为什么会这样?

我什至使用

mysqli_set_charset($mysqliConnection, 'utf8');
$mysqliConnection->query('SET NAMES `utf8` COLLATE `utf8_polish_ci`');

仍然是同样的问题。搜索了许多主题,但找不到与此相关的确切信息,也无法解决

更多代码:

$gameTitlesImploded = implode(', ', array_column($gamesArray, 'gamesQuery'));
$insertGamesQuery = "INSERT IGNORE INTO games(name, created_at) VALUES {$gameTitlesImploded}";
echo $insertGamesQuery;
die();
$mysqliConnection->query($insertGamesQuery);

回显后的insertGamesQuery是...

INSERT IGNORE INTO games(name, created_at) VALUES ("Hellblade: Senua's Sacrifice", now()), ("................

源代码:

INSERT IGNORE INTO games(name, created_at) VALUES ("Hellblade: Senua's Sacrifice", now()),

1 个答案:

答案 0 :(得分:-1)

我找到了解决方法。

解决方案是制作$title = html_entity_decode($title, ENT_QUOTES, 'utf-8');

回显该变量后,浏览器中似乎存在撇号,但实际上存在实体#039

html_entity_decode还不够。我必须申请ENT_QUOTES