Hello everyone ,
I have find i script made in 2013 that use Mysql , Today the mysql has removed and remplaced by Mysqli or PDO
Can any one help me please to convert the mysql code to mysqli
Exemple :

<?php
$num_queries = 0;
$total_time =   0;
class ADO
{
    function ADO($host,$user,$password,$database)
    {
        $this->connection=mysql_connect($host,$user,$password);
        if(!$this->connection)
        {
            echo "<br>Database Error!!!<br>".mysql_error();         
        }
        mysql_select_db($database);
    }

    function exec($sql)
    {   
    //  echo "<br />".$sql;
        //exit;
//      global $num_queries;
//      global  $total_time;
//      $num_queries++;     
//      $start_time = microtime(true);
//      echo "<br />".$num_queries." ".$sql;
        $result=mysql_query($sql,$this->connection)  ;
        if(!$result)
            echo "<p>ERROR::".mysql_error()."<br><strong>".$sql."</strong></p>";
//      $time_taken = round(microtime(true) - $start_time, 4 );
//      $total_time +=  $time_taken ;
//      if($time_taken >= 0.01)
//          echo "<br /> Time taken is ".$time_taken.' total time is  '.$total_time;
    //  echo $sql;
    //  exit;
        if($result)
        {
            return $result;
        }
        else
        {
            //echo "<br>Error in Query!!! $sql<br>".mysql_error();
            return false;
            //exit();           
        }
    }

    function error()
    {
        return mysql_error();
    }
    function affected_rows()
    {
        return mysql_affected_rows();
    }

    function fetch($result)
    {

        $res = mysql_fetch_array($result);
    //  echo mysql_error();
        return $res;
    }

    function fetch_assoc($result)
    {
        return mysql_fetch_assoc($result);
    }

    function free($result)
    {
        return mysql_free_result($result);
    }

    function count($result)
    {
        return mysql_num_rows($result);
    }

    function count_res($result)
    {

            return @mysql_num_rows($result);

    }

    function id()
    {
        return mysql_insert_id();
    }

    function end()
    {
        mysql_close($this->connection);
    }
}

global $ado;
$ado = new ADO($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME) or die("database connection error");

While the mysql_* functions were procedural, MySQLi supports either procedural or object oriented methods. Since you're already using procedural style, the simplest thing to do would be to replace the functions with their MySQLi counterparts.

I think you should just be able to replace:

And so on, and so forth ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.