mysqli stands for MySQL Improved, and it is a PHP extension used to interact with
MySQL databases. It provides an object-oriented interface (as opposed to the procedural
interface provided by the older mysql extension) for working with MySQL databases,
offering improved security and additional features.
To connect to a MySQL database using mysqli, you typically follow these steps(Establish the connection):
Create variable
Create connection
<?php
$host
== "localhost";
$password
== "your_password";
$database
== "your_database";
$connection
=
mysqli_connect
($host, $username, $password, $database) or
die
("Connection failed: " . mysqli_connect_error());
? >
<!DOCTYPE html> <html> <body> <?php # if statement in php $host == "localhost";
$username == "root";
$password == "";
$database == "firstDatabase";
$connection = mysqli_connect ($host, $username, $password, $database) or die ("Connection failed: " . mysqli_connect_error());
# if no error ,you have successfully connected to database ?> </body> </html>