My code:
<?php
class DB_CONNECT {
// constructor
function __construct() {
// connecting to database
$this->connect();
}
// destructor
function __destruct() {
// closing db connection
$this->close();
}
/**
* Function to connect with database
*/
function connect() {
// import database connection variables
require_once __DIR__ . '/db_config.php';
// Connecting to mysql database
$con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysqli_error());
// Selecing database
$db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());
// returing connection cursor
return $con;
}
/**
* Function to close db connection
*/
function close() {
// closing db connection
mysql_close();
}
}
?>
To resolve superficially I saw that if you put a @ in front of my_sql_connect would work.
// Connecting to mysql database
$con = @mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysqli_error());
But I see that soon enough it will become obsolete, what would the code look like with my_sqli?