Vidyalelo
MySQL · Q381

MySQL

Programming · MySQL · question 381

Q381

For failure, mysql_query() returns . . . . . . . .

A.
0
B.
1
C.
-1
D.
a non-zero
Answer

Answer: Option D

Solution

Answer: Option D
Solution:
This question is asking about how MySQL's `mysql_query()` function behaves when a query fails.

`mysql_query()` is a function used to execute SQL queries in MySQL. It returns a value that tells you whether the query was successful or not.

Here's how it works:

* If the query is successful, `mysql_query()` returns a non-zero value (usually a resource ID). * If the query fails, `mysql_query()` returns `FALSE` (which is equivalent to `0`).

Therefore, the correct answer is Option A: 0.

Important Note:

The `mysql_query()` function is considered deprecated in newer versions of PHP. It's recommended to use the MySQLi or PDO extensions for interacting with MySQL databases instead.