mysqli Getting started with mysqli

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

MySQLi is a PHP Extension which enables PHP to communicate with MySQL Databases. MySQLi comes built in with PHP. MySQLi was introduced with PHP 5.0.

MySQLi is available in procedural & Object Oriented style. MySQLi supports CRUD queries, prepared statements,Multiple statements,Transaction and SQL operations.

Before MySQLi, MySQL (Note: Its not MySQLi ) is the Default extension of PHP for connecting MySQL database. Due to several vulnerabilities in MySQL extention,MySQLi was introduced.

Installation or Setup

MySQLi is a PHP Extension which enables PHP to communicate with MySQL Databases. MySQLi comes built in with PHP. MySQLi was introduced with PHP 5.0.

For More details about Installations Refer official PHP MySQLi Documentation

MySQLi Basic Example in Procedural Style

<?php 
//Creating Connection to MySQL database using MySQLi
$mysqli = mysqli_connect("IP ADDRESS OR DOAMIN", "username", "password", "database_name");

//Executing Query in the Database using MySQLi
$result = mysqli_query($mysqli, "SELECT * FROM TABLE");

//Getting Results from MySQL 
$row = mysqli_fetch_assoc($result);
echo $row[columnName];

//Closing connection to the Database
$mysqli_close($mysqli);

?>
 


Got any mysqli Question?