PHP Database Connection
PHP Database Connection - Important Points
1. | What is the function used to establish a connection to a MySQL database in PHP? |
---|
A. my_sqli_connect()
B. mysql_connect()
C. pdo_connect()
D. mysqli_connect()
View Answer Discuss Work SpaceAnswer: option d
Explanation:
2. | Which of the following is the correct syntax to connect to a MySQL database in PHP? |
---|
A. $conn = mysqli_connect("localhost", "username", "password", "database_name");
B. $conn = mysql_connect("localhost", "username", "password", "database_name");
C. $conn = pdo_connect("localhost", "username", "password", "database_name");
D. None of the above
View Answer Discuss Work SpaceAnswer: option a
Explanation:
3. | Which of the following functions is used to close a database connection in PHP? |
---|
A. mysqli_close()
B. mysql_close()
C. pdo_close()
D. None of the above
View Answer Discuss Work SpaceAnswer: option a
Explanation:
4. | Which of the following functions is used to select a database in PHP? |
---|
A. my_sqli_select_db()
B. mysql_select_db()
C. pdo_select_db()
D. mysqli_select_db()
View Answer Discuss Work SpaceAnswer: option d
Explanation:
5. | Which of the following functions is used to execute a query in PHP? |
---|
A. mysqli_query()
B. mysql_query()
C. pdo_query()
D. None of the above
View Answer Discuss Work SpaceAnswer: option a
Explanation: