gpt4 book ai didi

php - 包含双引号的字符串在数据库中插入不完整

转载 作者:行者123 更新时间:2023-12-02 07:13:09 24 4
gpt4 key购买 nike

已更新我在表单中提供的文本区域将用户输入作为字符串

包含双引号的字符串在数据库中插入不完整..

我在文本区域中插入了一个字符串作为

"Don't worry too much about layout/design/text size, we will often "spice up" (i.e. bold, italic, spacing) your banner for a better overall look.

当我将字符串插入数据库时​​,字符串结束于

Don't worry too much about layout/design/text size, we will often

并被部分插入..我应该怎么做才能插入所有的单引号和双引号?

EDIT ON REQUEST

下面是我使用 php 插入数据库的查询

"insert into products_description (products_id, products_name, products_logo_name1, products_logo_name2, products_logo_name3, products_description) values ('" . (int)$products_id . "', 'banner_" . $products_id . "','".$_POST['logoimage1']."', '".$_POST['logoimage2']."', '".$_POST['logoimage3']."', '".mysql_real_escape_string($_POST['description'])."')"

这里 mysql_real_escape_string($_POST['description']) 没有转义双引号,因此在插入时截断应该做什么?

最佳答案

转义字符串中的双引号,如下所示:

$theString = "Hello, i wonder what all these \"quotes\" are doing in here...";

反斜杠会告诉编译器忽略后面双引号的“含义”,并将其视为普通字符(这就是我们所说的“转义”)。

另请查看 mysql_real_escape_string()在处理用户输入时(这将自动转义字符串中的所有危险元素,以便在 mySQL 数据库中使用)。

关于php - 包含双引号的字符串在数据库中插入不完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3716468/

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