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

2k Views Asked by At

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

There are 1 best solutions below

1
On

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