AMP

Chapter 9: Connecting PHP and MYSQL — Online MCQ Test

COMPUTER APPLICATIONS · CLASS 12th · Tamil Nadu State Board
Practice Chapter 9: Connecting PHP and MYSQL with a free chapter-wise online MCQ test. This chapter covers: This chapter covers database connectivity using PHP and MySQL. Students learn to establish server connections select databases execute SQL queries process database recordsets and c.... AI-generated questions from basic to board-exam level, with instant results and explanations.

Start Exam on Full Site →

Chapter 9: Connecting PHP and MYSQL — Important Questions & Answers

Which PHP function is commonly used to establish a connection with a MySQL database server?
  • A. mysqli_connect()
  • B. mysql_select_db()
  • C. mysqli_query()
  • D. mysqli_close()
Answer: A. mysqli_connect()
The mysqli_connect() function is used to connect PHP with the MySQL server by providing host, username, password, and database details.
Which function is used to select a database after connecting to the MySQL server?
  • A. mysqli_connect()
  • B. mysqli_select_db()
  • C. mysqli_fetch_array()
  • D. mysqli_close()
Answer: B. mysqli_select_db()
mysqli_select_db() selects the required database on the connected MySQL server for further operations.
Which SQL statement is usually used to retrieve records from a MySQL table?
  • A. INSERT
  • B. SELECT
  • C. UPDATE
  • D. DELETE
Answer: B. SELECT
SELECT is used to fetch data from one or more tables in a database.
A student wants to display all employees whose salary is greater than 50000. Which SQL query is most suitable?
  • A. SELECT * FROM employee WHERE salary > 50000;
  • B. INSERT INTO employee VALUES (salary > 50000);
  • C. UPDATE employee SET salary > 50000;
  • D. DELETE FROM employee WHERE salary > 50000;
Answer: A. SELECT * FROM employee WHERE salary > 50000;
A SELECT query with a WHERE condition is used to retrieve specific records that satisfy the condition.
Which statement about mysqli_connect() is correct?
  • A. It both connects to the server and selects the database automatically in all cases
  • B. It is used to establish a connection between PHP and MySQL server
  • C. It is used only to fetch records from a table
  • D. It closes the database connection after query execution
Answer: B. It is used to establish a connection between PHP and MySQL server
mysqli_connect() creates the connection between PHP and the MySQL server. Database selection and query execution are separate steps.