How can you make a connection with mysql server using php?



How can you make a connection with mysql server using php?..

Answer / Ekant Srivastava

To connect to a MySQL server using PHP, you can use the mysqli extension. Here's an example:nn```phpn$connection = new mysqli('localhost', 'username', 'password', 'database');nif ($connection->connect_error) {n die("Connection failed: " . $connection->connect_error);n}n``` Replace 'localhost', 'username', 'password', and 'database' with your server details.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

Does php need html?

1 Answers  


What are magic constants in php?

1 Answers  


What are default session time and path?

1 Answers  


This is regarding file uploading. 1. Who will be the owner of the uploaded file ? 2. What permission you will give for an uploaded file ? 3. What is mean by user, group and others and what kind of permission you will give for each user and explain the reason?

1 Answers   IBM,


Are there regular expressions in php?

1 Answers  


What is the $_ server php_self variable?

1 Answers  


What are the limitations or drawbacks of PHP ?

4 Answers   iDream,


How can you associate a variable with a session?

1 Answers  


Are static variables final?

1 Answers  


Write a program to get second highest number in an array using php?

1 Answers  


Which character is used to match exactly one character?

1 Answers  


How are cookies created?

1 Answers  


Categories