html表单代码-
<td width="75">
<input name="txtQty[]" type="text" id="txtQty[]" size="5"
value="<?php echo $ct_qty; ?>" class="box" onKeyUp="checkNumber(this);">当我提交表格时,我会调用以下脚本-
if (!get_magic_quotes_gpc()) {
if (isset($_POST)) {
foreach ($_POST as $key => $value) {
$_POST[$key] = trim(addslashes($value));
}
}
if (isset($_GET)) {
foreach ($_GET as $key => $value) {
$_GET[$key] = trim(addslashes($value));
}
}
}错误-
C:\xampp\htdocs\shizin\products\library\config.php警告:add斜杠()希望参数1是string,在第53行的
中给出的数组
我认为这个脚本只是用来修剪输入,但是我不知道这个addslash函数做什么,为什么会出现这个错误。
发布于 2010-12-02 09:36:48
如果将此代码应用于int值,则可以如下所示删除这些函数
if (!get_magic_quotes_gpc()) {
if (isset($_POST)) {
foreach ($_POST as $key => $value) {
$_POST[$key] = $value;
}
}
if (isset($_GET)) {
foreach ($_GET as $key => $value) {
$_GET[$key] = $value;
}
}
} 发布于 2010-08-17 07:28:01
在收到用户提供的数据后,您必须使用剥离斜杠,用魔术引号添加,而不是添加。
因此,您将需要2个代码片段。
第一个是来自http://www.php.net/manual/en/function.stripslashes.php的http://www.php.net/manual/en/function.stripslashes.php()
在你告诉我们,为什么你认为你需要你发布的代码之后,你会得到第二个。
发布于 2010-08-17 07:26:58
错误说,addslashes函数试图引用带有斜杠的字符串,但是$value参数不是字符串是数组,什么包含$_GET?
这是因为调用此脚本的页面传递一个数组。txtQty[]
http://php.net/manual/en/function.addslashes.php
https://stackoverflow.com/questions/3500182
复制相似问题