Examveda

What does mysql_query() return on failure?

A. 0

B. 1

C. -1

D. a non-zero

Answer: Option D

Solution (By Examveda Team)

This question is about how MySQL tells you if a query failed. Think of it like trying to open a door. Sometimes it opens (success!), and sometimes it doesn't (failure!).

In MySQL, the `mysql_query()` function is like trying to open that door. When it works, it means your query was successful. But if it fails, you need a way to know.

Here's how `mysql_query()` signals failure:
* Option A: 0 - This is actually the signal for success! It means the door opened.
* Option B: 1 - This is *not* the failure signal. It's just another number that *doesn't* indicate a problem.
* Option C: -1 - This *could* be the failure signal, depending on the specific MySQL version and setup.
* Option D: a non-zero - This is the most common way `mysql_query()` indicates failure. A non-zero number (like 2, 3, or anything other than 0) means the door didn't open.

So, the answer is Option D: a non-zero. It's the most reliable way for `mysql_query()` to let you know your query didn't work.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous