PHP Error- filter_input() expects parameter 3 to be integer, string given [duplicate]

偶尔善良 提交于 2021-02-05 12:27:13

问题


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() expects parameter 3 to be integer, string given

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

回答1:


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


来源:https://stackoverflow.com/questions/48140776/php-error-filter-input-expects-parameter-3-to-be-integer-string-given

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!