Here is my mysqli connection code
config.php
<?php
//site specific configuration declartion
define( 'BASE_PATH', 'http://localhost/user_login/');
define( 'DB_HOST', 'localhost' );
define( 'DB_USERNAME', 'root');
define( 'DB_PASSWORD', '');
define( 'DB_NAME', 'login');
function __autoload($class)
{
$parts = explode('_', $class);
$path = implode(DIRECTORY_SEPARATOR,$parts);
require_once $path . '.php';
}
?>
DBclass
<?php
class Cl_DBclass
{
/**
* @var $con vai realizar conexão com o banco
*/
public $con;
/**
* Isto irá criar uma conexão de banco de dados
*/
public function __construct()
{
$this->con = mysqli_connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
if( mysqli_connect_error()) echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
}
?>
Thanks in advance!