mysqli

Getting started with mysqli

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);

?>

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow