Complete the code to execute a SQL query using the query method.
$result = $conn->[1]("SELECT * FROM users");
The query method is used to execute SQL statements in PHP's mysqli.
Complete the code to check if the query was successful.
if ($result === [1]) { echo "Query failed."; }
true instead of false.null which is not returned by query failures.The query method returns false on failure.
Fix the error in the code to fetch rows from the query result.
while ($row = $result->[1]()) { echo $row['name']; }
fetch_row() returns numeric indexes, not associative keys.fetch_object() returns an object, not an array.fetch_assoc() returns an associative array, allowing access by column names.
Fill both blanks to execute a query and check if it succeeded.
$result = $conn->[1]($sql); if ($result === [2]) { echo "Error in query."; }
execute instead of query.true instead of false.Use query to run the SQL and check if the result is false to detect errors.
Fill all three blanks to fetch and print all user names from the query result.
$result = $conn->[1]($sql); while ($row = $result->[2]()) { echo $row[[3]] . "\n"; }
fetch_row() and trying to access by column name.Use query to run the SQL, fetch_assoc() to get associative arrays, and access the 'name' column.
