How do you connect MySQL database with PHP?



How do you connect MySQL database with PHP?..

Answer / Jinkal Chaudhary

To connect a MySQL database with PHP, you can use functions like `mysql_connect()` or the more modern `PDO` (PHP Data Objects) and MySQLi (MySQL Improved Extension). With `mysql_connect()`, you provide the hostname, username, password, and database name as arguments. For PDO, you create a new instance of it and call `setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)` to handle errors.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More MySQL Interview Questions

How to present a past time in hours, minutes and seconds?

1 Answers  


When to use order by in delete statement?

1 Answers  


What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?

2 Answers  


How do I setup a mysql database?

1 Answers  


How do I change directories in mysql?

1 Answers  


What is mysql routine?

1 Answers  


How do I restore a database in mysql workbench?

1 Answers  


How to set the time zone for MySQL to particular country time?

1 Answers  


What is the latest mysql version?

1 Answers  


How do you create a new database in mysql?

1 Answers  


How many TRIGGERS are allowed in MySql table?

1 Answers  


What is the difference between primary and unique key

5 Answers   CSC,


Categories