Connecting PHP with MySQL

<?php
$conn = new mysqli("localhost", "root", "", "testdb");

if ($conn->connect_error) {
die("Connection failed: " . $conn-&gt;connect_error);
} echo "Connected successfully!"; ?>

Explanation:

  • mysqli is used to connect PHP with MySQL database.
  • Replace "localhost", "root", "", "testdb" with your DB credentials.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *