Asked 3 years ago
26 Jul 2021
Views 648
Norberto

Norberto posted

Warning: mysqli_escape_string() expects exactly 2 parameters


$empname='Emp 1';
$insert="insert into employee ('name') values('".mysqli_escape_string($empname)."')";
mysqli_query($connection,$insert)


i am getting warning that mysqli_escape_string() expects exactly 2 parameters
duglus

duglus
answered Jul 27 '21 00:00

you should pass mysqli object to mysqli_escape_string .

syntax
mysqli_real_escape_string(mysqli $mysql, string $string): string

you need to pass two-argument mysqli object and string value as second argument.

so in your code , following change required :


$empname='Emp 1';
$insert="insert into employee ('name') values('".mysqli_escape_string($connection,$empname)."')";
mysqli_query($connection,$insert)



Post Answer