gpt4 book ai didi

PHP PDO 在更新时转义双引号

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

在我的本地环境中,一切正常,但当我在 GoDaddy 上移动我的网站并尝试更新帖子时,每个双引号前面都会添加一个“\”。

$sql = 'UPDATE '.$_REQUEST['id'].' SET description_'.$_REQUEST['lang'].' = :desc where id = 1';

try
{
$prepare = $bd->BD_Interne->prepare($sql);
$result = $prepare->execute(array(":desc" => $_REQUEST['raw_desc']));
$_SESSION['update'] = "good";
}
catch(PDOException $e)
{
$_SESSION['update'] = "bad";
echo $e->getMessage();
}

这是mysql配置问题还是我必须在php中做一些事情?

最佳答案

也许这是指令ma​​gic_quotes_gpc的工作请参阅:http://php.net/manual/en/function.addslashes.php

function addslashes returns a string with backslashes before characters that need to be escaped. These characters are single quote ('), double quote ("), backslash () and NUL (the NULL byte).

The PHP directive magic_quotes_gpc was on by default before PHP 5.4,and it essentially ran addslashes() on all GET, POST, and COOKIE data.

您可以在此处阅读如何在 GoDaddy 上禁用魔术引号:https://uk.godaddy.com/help/disable-magic-quotes-8383

关于PHP PDO 在更新时转义双引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35761315/

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