How to put db_connect with my_sqli [duplicate]

1

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?

    
asked by anonymous 19.08.2015 / 16:51

1 answer

0

Connection is made with

$conexao = mysqli_connect("localhost", "user", "pass", "banco_de_dados");

and closed with

mysqli_close($conexao); 
    
19.08.2015 / 16:56