Sidney Sousa
Sidney Sousa

Reputation: 3614

Opencart new version not working on localhost

I was given an Opencart website that was on a live server so I can run on my localhost(xampp).

Initially, I had changed both config files to this:

<?php
// HTTP
define('HTTP_SERVER', 'http://safetyelite.co.za/');
define('HTTP_IMAGE', 'http://safetyelite.co.za/image/');
define('HTTP_ADMIN', 'http://safetyelite.co.za/admin/');

// HTTPS
define('HTTPS_SERVER', 'http://safetyelite.co.za/');
define('HTTPS_IMAGE', 'http://safetyelite.co.za/image/');

// DIR
define('DIR_APPLICATION', 'C:/xampp/htdocs/safetyelite');
define('DIR_SYSTEM', 'C:/xampp/htdocs/safetyelite/system/');
define('DIR_DATABASE', 'C:/xampp/htdocs/safetyelite/system/database/');
define('DIR_LANGUAGE', 'C:/xampp/htdocs/safetyelite/admin/language/');
define('DIR_TEMPLATE', 'C:/xampp/htdocs/safetyelite/admin/view/template/');
define('DIR_CONFIG', 'C:/xampp/htdocs/safetyelite/system/config/');
define('DIR_IMAGE', 'C:/xampp/htdocs/safetyelite/image/');
define('DIR_CACHE', 'C:/xampp/htdocs/safetyelite/system/cache/');
define('DIR_DOWNLOAD', 'C:/xampp/htdocs/safetyelite/download/');
define('DIR_LOGS', 'C:/xampp/htdocs/safetyelite/system/logs/');
define('DIR_CATALOG', 'C:/xampp/htdocs/safetyelite/catalog/');

// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'safetyelite');
define('DB_PREFIX', '');
?>

Then in my index.php I changed the website directory:

if (!defined('DIR_APPLICATION')) {
    header('Location: /http://localhost/safetyelite/install/index.php');
    exit;
}

// VirtualQMOD
require_once('vqmod/vqmod.php');
$vqmod = new VQMod();

When I refreshed the page it gave me this error:

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\xampp\htdocs\safetyelite\system\database\mysql.php on line 6

My config files and index.php look like this now and I don't know what else to do so I hope you can help:

Then I upgraded my vqmod folder to the latest one.

In my config files I changed define('DB_DRIVER', 'mysql');

for this: define('DB_DRIVER', 'mmysqli');

the mysqli file looks like this:

<?php
final class mMySQLi {
    private $mysqli;

    public function __construct($hostname, $username, $password, $database) {
        $this->mysqli = new mysqli($hostname, $username, $password, $database);

        if ($this->mysqli->connect_error) {
            trigger_error('Error: Could not make a database link (' . $this->mysqli->connect_errno . ') ' . $this->mysqli->connect_error);
        }

        $this->mysqli->set_charset('utf8');
    }

    public function query($sql) {
        $query = $this->mysqli->query($sql);

        if ($this->mysqli->errno) {
            trigger_error('Error: ' . $this->mysqli->error . '<br />Error No: ' . $this->mysqli->errno . '<br />' . $sql);
            exit();
        }

        if ($query) {
            if (isset($query->num_rows)) {
                $result = new stdClass();
                $data = array();

                while ($row = $query->fetch_assoc()) {
                    $data[] = $row;
                }

                $result->row = isset($data[0]) ? $data[0] : array();
                $result->rows = $data;
                $result->num_rows = $query->num_rows;

                $query->close();

                unset($data);

                return $result;
            } else {
                // When MySQLi returns boolean true instead of a result object
                // http://www.php.net/manual/en/mysqli.query.php
                $result = new stdClass();
                $result->row = array();
                $result->rows = array();
                $result->num_rows = 0;

                return $result;
            }
        } else {
            trigger_error('Error: ' . $this->mysqli->error . '<br />Error No: ' . $this->mysqli->errno . '<br />' . $sql);
            exit();
        }
    }

    public function escape($value) {
        return $this->mysqli->real_escape_string($value);
    }

    public function countAffected() {
        return $this->mysqli->affected_rows;
    }

    public function getLastId() {
        return $this->mysqli->insert_id;
    }

    public function __destruct() {
        $this->mysqli->close();
    }
}
?>

When I refresh the page, I see no more errors but everything is blank. I checked with the inspector and all is blank. Is there anything I am possibly missing?

Hope you can help.

Upvotes: 0

Views: 748

Answers (1)

5eeker
5eeker

Reputation: 1027

If you are using linux (ubuntu) you can check the error log for clue.

in terminal type :

sudo tail -f /var/log/apache2/error.log

Refer below snapshot

enter image description here

Using this you will get some clue. I think you have PHP version 7.* , in which Mysql old functions are deprecated.

Upvotes: 2

Related Questions