Opencart新版本无法在localhost

时间:2017-07-25 07:51:26

标签: php mysql opencart

我获得了一个在实时服务器上的Opencart网站,因此我可以在我的localhost(xampp)上运行。

最初,我已将两个配置文件更改为:

<?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', '');
?>

然后在我的index.php中,我更改了网站目录:

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

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

当我刷新页面时,它给了我这个错误:

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:

然后我将我的vqmod文件夹升级到最新版本。

在我的配置文件中,我改变了 define('DB_DRIVER', 'mysql');

为此: define('DB_DRIVER', 'mmysqli');

mysqli文件如下所示:

<?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();
    }
}
?>

当我刷新页面时,我看到没有更多错误,但一切都是空白的。我检查了检查员,一切都是空白的。 有什么我可能遗失的吗?

希望你能提供帮助。

1 个答案:

答案 0 :(得分:2)

如果您使用的是linux(ubuntu),可以查看错误日志以获取线索。

终端类型

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

参考下面的快照

enter image description here

使用它你会得到一些线索。我认为你有PHP版本7. *,其中不推荐使用Mysql旧函数。