Vidyalelo
MySQL · Q192

MySQL

Programming · MySQL · question 192

Q192

How many among the following use NULL to indicate failure? mysql_init(), mysql_real_connect()

A.
0
B.
1
C.
2
Answer
D.
3

Answer: Option C

Solution

Answer: Option C
Solution:
This question is asking about how functions in MySQL handle errors. In particular, it wants to know if they use NULL to signal that something went wrong.

Let's look at the two functions:

* mysql_init(): This function initializes a MySQL connection. It doesn't directly interact with the database. If it fails, it will usually return NULL, indicating an error.
* mysql_real_connect(): This function attempts to establish a connection to a MySQL server. If it fails to connect, it will also return NULL.

Therefore, the correct answer is Option C: 2. Both mysql_init() and mysql_real_connect() use NULL to indicate a failure.