Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5

MySQLi Connect
#1

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();
 }
?>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)