How can we connect a database using php?

How can we connect a database using php?

To connect the database using php we use the following code.

$conn = mysqli_connect("localhost","username","password","db_name");

where:
localhost = Host name
username = MySQL username
password = MySQL password
db_name = Database name to connect.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.