Saturday, October 27, 2018

MySql vs MySqli

Basically, MySQL is the old database driver, and MySQLi is the Improved driver. The "i" stands for "improved" so it is MySQL improved.
MySQLi can be done procedural and object-oriented whereas MySQL can only be used procedurally. Mysqli also supports prepared statements which protect from SQL Injection.

MySQL extension added in PHP version 2.0. and deprecated as of PHP 5.5.0.

MySQLi extension added in PHP 5.5 and will work on MySQL 4.1.3 or above.

Connect with MySqli :-

<?php
define('DB_SERVER','localhost');
define('DB_USER','database_user_name');
define('DB_PASS' ,'db_password');
define('DB_NAME', 'db_name');
$con = mysqli_connect(DB_SERVER,DB_USER,DB_PASS,DB_NAME);
if (mysqli_connect_errno())
{
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>

Connect with MySql :-


 <?php
         $dbhost = 'localhost';
         $dbuser = 'db_username';
         $dbpass = 'db_password';
         $conn = mysql_connect($dbhost, $dbuser, $dbpass);
         
         if(! $conn ) {
            die('Could not connect: ' . mysql_error());
         }
         echo 'Connected successfully';
         mysql_close($conn);
      ?>

For any quary, suggesion, advice about this topic kindly Comment below.


Related Posts:

  • Php Mysql Login Video Tutorial Read More
  • History Of PHP The History Of Php  PHP is an "HTML-embedded scripting language" primarily used for dynamic Web applications. The first part of this definition means that PHP code can be interspersed with HTML, making it sim… Read More
  • Create a MySQL Database Using MySQLi and PDO The following examples create a database named "myDB": <?php $servername = "localhost"; $username = "username"; $password = "password"; // Create connection$conn = new mysqli($servername, $us… Read More
  • Welcome To My Blog                                                               … Read More
  • Simple Login with php & mysql Creating the Database Table:- Execute the following SQL query to create the users table inside your MySql database. CREATE TABLE users ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, username VARCHAR(50) NOT NULL UN… Read More

1 comment: