Post by dbodemer » Mon Sep 21, 2020 7:46 am

Hello, I have an older version of opencart running. I'm getting the following error.
Screenshot is here, https://img.hostek.net/i/9f93cb14c4e0c708d2aa

Is there an easy fix? Is there a straight line to update to a newer version of OpenCart?

Newbie

Posts

Joined
Mon Sep 21, 2020 7:36 am

Post by OSWorX » Mon Sep 21, 2020 3:54 pm

dbodemer wrote:
Mon Sep 21, 2020 7:46 am
Hello, I have an older version of opencart running. I'm getting the following error.
Screenshot is here, https://img.hostek.net/i/9f93cb14c4e0c708d2aa

Is there an easy fix? Is there a straight line to update to a newer version of OpenCart?
The error comes from the used and outdated MySQL!
Deprecated and should not used anymore.
Use MySQLi instead which is the de-facto standard these days (if MySQL is used and not another database driver).

Because you are not writing which OpenCart version you are using (old is good, but how old ..?) and which php-version, giving a solution is not that easy für an update.
Updates can be made basically from every version, but it depends on the old and the new version how it shall and should be made.

To try it by yourself, download the latest version either from the 2.x branch (therefore 2.3.0.2) or 3.x (then 3.0.3.6) install it new in a seperate folder and migrate your database manually.
This is the safiest and cheapest way to do an Update.
Do not use the standard upgrade routine, because this will bring you more troubles you might expect!

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by dbodemer » Tue Sep 22, 2020 7:39 am

Is there a place in the codebase to find out what version is being used?. Since the site and admin section is dead in the water, can I make a copy of mysql.php and mysqli.php and then move the contents to mysqli.php to mysql.php and at least get a connection?

Newbie

Posts

Joined
Mon Sep 21, 2020 7:36 am

Post by IP_CAM » Tue Sep 22, 2020 8:45 am

Either download one of them:
https://www.opencart.com/index.php?rout ... load_id=36
Or then use the file I use ( shown below, v.1.5.6.x ), to enable mysqli
---
Then, change in BOTH of your config.php Files ( Front + Admin )
This Line:

Code: Select all

// DB
define('DB_DRIVER', 'mysql');
To this one:

Code: Select all

// DB
define('DB_DRIVER', 'mysqli');
---
system/database/mysqli.php

Code: Select all

<?php
final class DBMySQLi {
	private $link;

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

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

		$this->link->set_charset("utf8");
		$this->link->query("SET SQL_MODE = ''");
	}

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

		if (!$this->link->errno){
			if (isset($query->num_rows)) {
				$data = array();

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

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

				unset($data);

				$query->close();

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

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

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

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

	public function __destruct() {
		$this->link->close();
	}
}
?>
That should be it ! Good Luck :D
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by dbodemer » Tue Sep 22, 2020 9:02 am

Ok I have updated and now Iget that the DIR_System is not being set.

Newbie

Posts

Joined
Mon Sep 21, 2020 7:36 am

Post by dbodemer » Tue Sep 22, 2020 9:13 am

I did use the file that you provided. I might be on version 1.0 of the software. Is there a way to determine what version this site is using?
Here is the actual message in the logs.

[21-Mar-2019 09:26:55 America/Chicago] PHP Notice: Use of undefined constant DIR_SYSTEM - assumed 'DIR_SYSTEM' in /home/mindourb/public_html/ocart/system/startup.php on line 77
[21-Mar-2019 09:26:55 America/Chicago] PHP Warning: require_once(DIR_SYSTEMhelper/json.php): failed to open stream: No such file or directory in /home/mindourb/public_html/ocart/system/startup.php on line 77
[21-Mar-2019 09:26:55 America/Chicago] PHP Fatal error: require_once(): Failed opening required 'DIR_SYSTEMhelper/json.php' (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/mindourb/public_html/ocart/system/startup.php on line 77

Newbie

Posts

Joined
Mon Sep 21, 2020 7:36 am

Post by IP_CAM » Tue Sep 22, 2020 9:25 am

require_once(DIR_SYSTEMhelper/json.php)
should rather look like:
require_once(DIR_SYSTEM/helper/json.php)
you may have mistyped a link or path in a file, where that JSON Link exists,
and NOT added a forward SLASH '/' ... ???
Check your system/startup.php file on this, the problem itself might be
located in the config.php File, where that forward slash might be missing.
it should look like this:
define('DIR_SYSTEM', '/home/site/www/yoursite/shop/system/');
and NOT like this:
define('DIR_SYSTEM', '/home/site/www/yoursite/shop/system');
( PS: All those config.php Path-Lines require an ending forward SLASH! )
---
Usually, one can find the Version Number in the index.php file:
// Version
define('VERSION', '1.5.6.5 LIGHT');
Last edited by IP_CAM on Tue Sep 22, 2020 9:43 am, edited 1 time in total.

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by dbodemer » Tue Sep 22, 2020 9:43 am

It is version 1.5.6 and the variable is defined as follows.

define('DIR_SYSTEM', '/home/mindourb/public_html/ocart/system/');

Newbie

Posts

Joined
Mon Sep 21, 2020 7:36 am

Post by IP_CAM » Tue Sep 22, 2020 9:49 am

Well, it then only leaves one option, you possibly did NOT add a
forward SLASH to those lines in the config.php File, like:
// HTTP
define('HTTP_SERVER', 'http://www.openshop.li/shop/');
// HTTPS
define('HTTPS_SERVER', 'http://www.openshop.li/shop/');

still, that should not matter, when it comes to 'internal' linking ...
Good Luck!
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by dbodemer » Tue Sep 22, 2020 8:49 pm

This is from the config php file:
<?php
// HTTP
define('HTTP_SERVER', 'http://www.mindourbeeswax.com/ocart/');

// HTTPS
define('HTTPS_SERVER', 'http://wwww.mindourbeeswax.com/ocart/');

// DIR
define('DIR_APPLICATION', '/home/mindourb/public_html/ocart/catalog/');
define('DIR_SYSTEM', '/home/mindourb/public_html/ocart/system/');
define('DIR_DATABASE', '/home/mindourb/public_html/ocart/system/database/');
define('DIR_LANGUAGE', '/home/mindourb/public_html/ocart/catalog/language/');
define('DIR_TEMPLATE', '/home/mindourb/public_html/ocart/catalog/view/theme/');
define('DIR_CONFIG', '/home/mindourb/public_html/ocart/system/config/');
define('DIR_IMAGE', '/home/mindourb/public_html/ocart/image/');
define('DIR_CACHE', '/home/mindourb/public_html/ocart/system/cache/');
define('DIR_DOWNLOAD', '/home/mindourb/public_html/ocart/download/');
define('DIR_LOGS', '/home/mindourb/public_html/ocart/system/logs/');

// DB
define('DB_DRIVER', 'mysqli');


Thanks for all the help everyone.

Newbie

Posts

Joined
Mon Sep 21, 2020 7:36 am

Post by dbodemer » Tue Sep 22, 2020 10:50 pm

Here is the latest from the log file.

[22-Sep-2020 09:42:30 America/Chicago] PHP Warning: mysqli::mysqli(): (42000/1044): Access denied for user 'mindourb_ocar806'@'localhost' to database 'mindourb_ocar806' in /home/mindourb/public_html/ocart/system/library/db.php on line 12
[22-Sep-2020 09:42:30 America/Chicago] PHP Fatal error: Call to undefined method mysqli::escape() in /home/mindourb/public_html/ocart/system/library/db.php on line 20

Newbie

Posts

Joined
Mon Sep 21, 2020 7:36 am

Post by IP_CAM » Wed Sep 23, 2020 12:36 am

Contact your Hoster and ask him, if MySqli is enabled for your Site.

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by dbodemer » Fri Sep 25, 2020 7:06 am

Issue has been resolved. I did not get a full briefing yet on the fix but I am imagining that it involved teh db.php file.

Newbie

Posts

Joined
Mon Sep 21, 2020 7:36 am

Post by OSWorX » Fri Sep 25, 2020 1:20 pm

dbodemer wrote:
Fri Sep 25, 2020 7:06 am
Issue has been resolved. I did not get a full briefing yet on the fix but I am imagining that it involved teh db.php file.
For other may have the same problem, it would be nice if you could post the solution here.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria
Who is online

Users browsing this forum: No registered users and 214 guests