Mysql存储引号为'

Cli*_*ote 0 php mysql sql collation character-encoding

我有一些PHP代码,用于存储数据库中文本框中输入的内容.如果我输入bob's apples,它将被存储在数据库中bob's apples.

可能是什么问题?

存储它的表具有latin1_swedish_ci的排序规则.

cod*_*ict 5

看起来您的PHP代码正在HTML使用htmlentities将特殊字符转换为实体.您可以使用函数html_entity_decode来取回原始字符串.

$a = "bob's apples";
echo htmlentities($a,ENT_QUOTES);                                // bob's apples
echo html_entity_decode(htmlentities($a,ENT_QUOTES),ENT_QUOTES); //bob's apples
Run Code Online (Sandbox Code Playgroud)