Complete the code to prepare a SQL statement.
$stmt = $conn->[1]("SELECT * FROM users WHERE id = ?");
The prepare method creates a prepared statement to safely execute SQL queries.
Complete the code to bind a parameter to the prepared statement.
$stmt->[1]("i", $userId);
The bind_param method binds variables to the parameter markers in the SQL statement.
Fix the error in executing the prepared statement.
$stmt->[1]();The execute method runs the prepared statement with the bound parameters.
Fill both blanks to fetch the result from the executed statement.
$stmt->[1](); $stmt->[2]($name);
First, execute() runs the statement, then bind_result() binds variables to the columns in the result set.
Fill all three blanks to safely query and fetch a user's name by id.
$stmt = $conn->[1]("SELECT name FROM users WHERE id = ?"); $stmt->[2]("i", $id); $stmt->[3]();
This sequence prepares the statement, binds the integer parameter, and executes the query safely.
