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

// 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:

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