gpt4 book ai didi

mysql select 用主题标签替换双引号

转载 作者:行者123 更新时间:2023-11-29 10:47:59 24 4
gpt4 key购买 nike

我一直在阅读文档并搜索 google-net,试图找出如何为 mysql 构造一个返回 varchar 字段中的双引号的选择查询。

我发现的所有内容都表明不要首先插入引号而不转义它们。 100%同意...但是我从别人那里收到了数据库。他们使用 MySQL Workbench 创建它...这允许他们在 varchar 字段中输入双引号值。我到底如何才能恢复双引号? mysql 客户端(命令行)和 mysqli (php) 都将双引号转换为哈希标签。

我可以转储数据库,手动替换所有引号,然后重新导入。但这仅在我下次收到该数据库之前有效。

我在这里缺少什么?

(我尝试添加屏幕截图,但 Imagur 现在似乎不想处理它们)...所以这里是我所看到的内容的复制/粘贴:

在 MySQL Workbench 中(仅“值”字段):

If you would like to keep your responses anonymous, you may do so.  Simply click on the ”anonymous” checkbox above each ”Feedback” block.   When you submit your survey, you will be sent a link, by email, to revisit/modify your responses. Hold onto that email as that will be the only mechanism for associating you with your anonymous responses.

来自 mysql 客户端:

mysql> select * from survey_labels where item_id=149;
+---------+------+-------+--------+------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| item_id | type | level | italic | bold | size | value |
+---------+------+-------+--------+------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 149 | text | 2 | 0 | 0 | NULL | If you would like to keep your responses anonymous, you may do so. Simply click on the #anonymous# checkbox above each #Feedback# block. When you submit your survey, you will be sent a link, by email, to revisit/modify your responses. Hold onto that email as that will be the only mechanism for associating you with your anonymous responses. |
+---------+------+-------+--------+------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.09 sec)

最佳答案

我会使用PHPs function htmlspecialchars()将这些特殊字符转换为 html-codes

但是对于你的问题:找出你的工作台正在使用哪种编码,并确保你的 PHP 和 mysql 客户端使用相同的编码。您可以在工作台的创建脚本和客户端的选项中找到它。

还要检查该脚本是否确实存在双引号。

如果这没有任何结果,只需将数据库中的值更改为 ",因为您将使用该表 99% 作为前端输出,而只有 1% 通过工作台访问。

关于mysql select 用主题标签替换双引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44231466/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com