I'm converting from mysql_
to mysqli_
and still new to mysqli_
. Here is my code:
$stmt = mysqli_prepare($con, "INSERT INTO test VALUES (?, ?)");
mysqli_stmt_bind_param($stmt, 'ss', $a, $b);
$a=1;
$b=1.5;
mysqli_stmt_execute($stmt);
My question is:
$a has Integer value
$b float
but the corresponding variable type in mysqli_stmt_bind_param ss (string,string)
.
the result is data successfully inserted to table. Is it working as intended or am I doing it wrong?
Actually bind functions (mysqli_stmt_bind_param
or PDOStatement::bindParam
) are not validation functions. You show how to interpret your value only and what type of value you want to get from result.
Answer is: it is work as intended.