WebToTell

Full Version: MySQLi Connect
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
MySQLi is new OOP extension for php, most php programmers agreed that MySQL extension for php is old and not secure. There are many advantages to use MySQLi extention over MySQL. 

// mysqli, procedural way
$mysqli = mysqli_connect( 'localhost', 'username', 'password', 'database');

and
// mysqli, object oriented way
$mysqli = new mysqli( 'localhost', 'username', 'password', 'database');


Here is  easiest php example to connect to MySQL with MySQLi extension. 

PHP Code:
<?php
$connection 
mysqli_connect("host","user","password","db");

// Check connection
if (mysqli_connect_errno()) {
 echo 
"Failed to connect to MySQL: " mysqli_connect_error();
 }
?>