"how to use mysqli prepared statements?" Code Answer


from the mysqli::prepare docs:

the parameter markers must be bound to application variables using mysqli_stmt_bind_param() and/or mysqli_stmt_bind_result() before executing the statement or fetching rows.

bind_param docs.


$name = 'one';
$age  = 1;

$stmt = $mysqli->prepare("insert into users (name, age) values (?,?)");

// bind parameters. i'm guessing 'string' & 'integer', but read documentation.
$stmt->bind_param('si', $name, $age);

// *now* we can execute
By cmn on January 12 2022

Answers related to “how to use mysqli prepared statements?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.