I am in the process of making my mysql queries prepared in an attempt to increase security, however I have a problem when I attempt to fetch the results of a prepared statement. I can successfully fetch one row of data however I have had no success fetching an array of data. All of the research I have done has provided examples that either don't work or are way too complicated.
My Current Code
if ($stmt = $dbc->prepare("SELECT city FROM users WHERE id = ? LIMIT 1")) {
$stmt->bind_param('i', $id); // Bind id to parameter.
$stmt->execute(); // Execute the prepared query.
$stmt->store_result();
// get variables from result.
$stmt->bind_result($city);
$stmt->fetch();
}
This is my current code which only returns one result.