PHP Error- filter_input()期望参数3为整数,给定字符串

时间:2018-01-07 19:28:53

标签: php runtime-error user-input sanitization filter-input

我尝试创建一个将详细信息存储到数据库的表单,但是,当我尝试对输入进行整理/验证时,我不断收到以下错误

  

filter_input()期望参数3为整数,给定字符串

我的代码如下,任何有关如何对此进行排序的帮助都会很棒!

$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');

1 个答案:

答案 0 :(得分:1)

您需要使用常量,而不是这些常量的字符串表示。另外,请检查sanitize的拼写,例如

filter_input(INPUT_POST, 'FNAME', FILTER_SANITIZE_STRING);