У меня проблемы с моим заказом в MySqli на PHP.Это либо не работает bind_param, либо что-то еще.Я не уверен, что я здесь забываю, он просто не хочет принимать мою привязку.Заранее спасибо.
@ $db = new mysqli('localhost', 'root', '', 'books');
// if mysqli_connect_errno() is set, we did not successfully connect. Here we deal with the error.
if (mysqli_connect_errno()) {
echo 'Error: Could not connect to database. Please try again later.</body></html>';
die();
}
$sortOrder = 'title';
$query = "SELECT ISBN, Author, Title, Price FROM books ORDER BY ?";
$stmt = $db->prepare($query);
$stmt->bind_param('s', $sortOrder);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($isbn, $author, $title, $price);
echo "<p>Number of books found: " . $stmt->num_rows . "</p>";
$counter = 0;
if ($stmt->num_rows > 0) {
while ($stmt->fetch()) {
$newBook = new book($isbn, $author, $title, $price);
$bookList[$counter] = $newBook;
$counter++;
}
} else {
//Nothing
}
$stmt->free_result();
$db->close();