Answer the question
In order to leave comments, you need to log in
How to fix mysqli_num_rows error?
Hello, I have this code,
$result = mysqli_query($link, "SELECT * FROM `id` ORDER BY `data` DESC WHERE id = '1'");
$row_cnt = mysqli_num_rows($result);
Answer the question
In order to leave comments, you need to log in
in the query, first there should be WHERE , and then ORDER / GROUP BY
you have the opposite
You have an error in your request. From documentation:
Swap ORDER BY ... and WHERE ...
You can also add a check: after the first line, write if ($result) { ... }
. Better yet, use PDO instead of mysqli, because the former can throw exceptions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question