问题
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