My Youtube Channel

Please Subscribe

Flag of Nepal

Built in OpenGL

Word Cloud in Python

With masked image

Showing posts with label mysqli. Show all posts
Showing posts with label mysqli. Show all posts

Saturday, August 5, 2023

Will "mysqli" extension work for MariaDB database?

Yes, `mysqli` can work with MariaDB in PHP. The `mysqli` extension stands for "MySQL Improved" and is designed to work with both MySQL and MariaDB databases. MariaDB is a fork of MySQL, so they share a lot of similarities and are largely compatible with each other.

When you use the `mysqli` extension in PHP, you can connect to both MySQL and MariaDB databases using the same functions and methods. This is because the `mysqli` extension provides an improved and more feature-rich API for accessing MySQL and MariaDB databases in PHP.

Here's a simple example of connecting to a MariaDB database using `mysqli` in PHP:


<?php

$servername = "localhost";

$username = "your_username";

$password = "your_password";

$dbname = "your_database";


// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);


// Check connection

if ($conn->connect_error) {

    die("Connection failed: " . $conn->connect_error);

}


echo "Connected successfully";


// Close connection

$conn->close();

?>


Remember to replace `your_username`, `your_password`, and `your_database` with your actual database credentials.

So, whether you are working with MySQL or MariaDB, you can use `mysqli` in PHP to interact with the database effectively.