本文介绍了PHP Error- filter_input() 期望参数 3 是整数,给出字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个将详细信息存储到数据库的表单,但是,当我尝试清理/验证输入时,我不断收到以下错误
I'm trying to create a form that stores details to a database, however, when I try to sanatize/validate the inputs I keep getting the following error
filter_input() 期望参数 3 是整数,给定字符串
我的代码如下,任何关于如何排序的帮助都会很棒!
My code is as follows, any help on how to sort this would be great!
$customer->EMAIL = filter_input(INPUT_POST, 'EMAIL', 'FILTER_VALIDATE_EMAIL');
$customer->TITLE = 'TITLE';
$customer->FNAME = filter_input(INPUT_POST, 'FNAME', 'FILTER_SANATIZE_STRING');
$customer->LNAME = filter_input(INPUT_POST, 'LNAME', 'FILTER_SANATIZE_STRING');
$customer->DOB = filter_input(INPUT_POST, 'DOB', 'FILTER_VALIIDATE_DATE');
$customer->PHONE = filter_input(INPUT_POST, 'PHONE', 'FILTER_SANATIZE_STRING');
$customer->COUNTRY = filter_input(INPUT_POST, 'COUNTRY', 'FILTER_SANATIZE_STRING');
$customer->STAFF_NUM = filter_input(INPUT_POST, 'STAFF_NUM', 'FILTER_VALIDATE_INT');
$customer->SUBSCRIPTION = filter_input(INPUT_POST, 'SUBSCRIPTION', 'FILTER_SANATIZE_STRING');
$customer->PASSWORD = filter_input(INPUT_POST, 'PASSWORD', 'FILTER_SANATIZE_STRING');
推荐答案
您需要使用常量,而不是这些常量的字符串表示形式.另外,检查 sanitize
的拼写,例如
You need to use constants, not string representations of those constants. Also, check the spelling of sanitize
, e.g.
filter_input(INPUT_POST, 'FNAME', FILTER_SANITIZE_STRING);
这篇关于PHP Error- filter_input() 期望参数 3 是整数,给出字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!