What does it mean in PHP when mysqli_num_rows returns -1?

Asked

Viewed 119 times

-3

In a query to Mysql the return of the result brings the value of -1, what does this mean? I know that 0 is when it does not bring any results.

  • 2

    Edit the question and post the code to analyze it. There’s no way to know what caused it without knowing what you did. It may not even be that which is returning the -1, it may simply be confusion in the use of the code.

  • Remembering that even closed, the question can be edited. By [Edit] placing the code you open a possibility of reopening and better analysis of the real problem. In short, until the moment that can be concluded is what has already been answered below: the query failed, and you need to see which error returned by mysqli_error and/or mysqli_errno.

  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).

1 answer

3

Are you sure you got this in this role? A documentation does not indicate that this is possible, but does not indicate that it does not happen. The PHP documentation is really bad, so I think there might be a flaw there.

It almost certainly indicates an error in the function call. That is, it is not that there are no rows returned in the query, the query failed and not 0 lines it generated. Check if previous operations were successful.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.