php - Opencart 1.4.9 from mysql to mysqli -


my host has upgraded it's php version 5.5 , mysql 5.6.

we still using opencart 1.4.9.6 , cannot upgrade store live , have lot of own modifications.

right unable view our administration area , message shown on top of of our pages:

deprecated: mysql_connect(): mysql extension deprecated , removed in future: use mysqli or pdo instead in /home/public_html/system/database/mysql.php on line 8

how should proceed if want message disappear , able log in our admin pages? possible change mysql_connect mysqli?

here code used in mysql.php:

<?php final class mysql { private $connection;  public function __construct($hostname, $username, $password, $database) {      if (!$this->connection = mysql_connect($hostname, $username, $password)) {         exit('error: not make database connection using ' . $username . '@' . $hostname);     }      if (!mysql_select_db($database, $this->connection)) {         exit('error: not connect database ' . $database);     }      mysql_query("set names 'utf8'", $this->connection);     mysql_query("set character set utf8", $this->connection);      // mic changed 20100824 instead of set names , character set     // see: http://at2.php.net/manual/en/function.mysql-set-charset.php     //mysql_set_charset( 'utf8', $this->connection );      mysql_query("set character_set_connection=utf8", $this->connection);     mysql_query("set sql_mode = ''", $this->connection); }  public function query($sql) {     $resource = mysql_query($sql, $this->connection);      if ($resource) {         if (is_resource($resource)) {             $i = 0;              $data = array();              while ($result = mysql_fetch_assoc($resource)) {                 $data[$i] = $result;                  $i++;             }              mysql_free_result($resource);              $query = new stdclass();             $query->row = isset($data[0]) ? $data[0] : array();             $query->rows = $data;             $query->num_rows = $i;              unset($data);              return $query;         } else {             return true;         }     } else {         exit('error: ' . mysql_error($this->connection) . '<br />error no: ' . mysql_errno($this->connection) . '<br />' . $sql);     } }  public function escape($value) {     return mysql_real_escape_string($value, $this->connection); }  public function countaffected() {     return mysql_affected_rows($this->connection); }  public function getlastid() {     return mysql_insert_id($this->connection); }  public function __destruct() {     mysql_close($this->connection); } } ?> 

how should proceed if want message disappear , able log in our admin pages?

  • open file <oc_root>/system/startup.php
  • change line:
    error_reporting(e_all)
    to
    error_reporting(e_all ^ e_deprecated) , deprecation warnings disappear

is possible change mysql_connect mysqli?

i don't know if oc 1.4.9 has built in driver mysqli, check that, open directory <oc_root>/system/database , make sure there file named mysqli.php, if it's there, apply following steps: (if not, need change mysql_* functions in project)

  • open configuration files <oc_root>/config.php , <oc_root>/admin/config.php
  • change line:
    define('db_driver', 'mysql')
    to
    define('db_driver', 'mysqli')

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -