PHP中的addslashes()函数期间发生错误 [英] error during addslashes() function in php

查看:124
本文介绍了PHP中的addslashes()函数期间发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

html表单代码-

<td width="75">
<input name="txtQty[]" type="text" id="txtQty[]" size="5" 
 value="<?php echo $ct_qty; ?>" class="box" onKeyUp="checkNumber(this);">

提交表单时,我会调用以下脚本-

when I submit form I calls following script-

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));
    }
}   
}

错误-

警告:addslashes()期望参数1为字符串,第53行的C:\ xampp \ htdocs \ shizin \ products \ library \ config.php中给出的数组

Warning: addslashes() expects parameter 1 to be string, array given in C:\xampp\htdocs\shizin\products\library\config.php on line 53

我认为此脚本仅用于修剪输入,但我不知道此addlash函数的作用以及为什么会出现此错误.

I think this script is being used just to trim input but I dont know what this addslash function does and why this error coming.

推荐答案

如果将此代码应用于int值,则可以像这样删除这些功能

If you apply this code on an int value then you remove these function like this

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; 
    } 
}    
} 

这篇关于PHP中的addslashes()函数期间发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆