Post by frankjreda » Sun Jan 24, 2016 1:27 am

Hi there,

I've been running Opencart 1.5.5.1 for a few years with no issue. Back in December 2015, I suddenly started getting the following error when loading the main store page:

Fatal error: Cannot redeclare class MySQLi in .../webstore/system/database/mysqli.php on line 2

As far as I can tell, nothing has changed (at least I didn't change anything). It is possible that my hosting company (Dreamhost) changed something, but I'm not sure what.

I've searched the forums and Googled the error, but I can't find anything relevant, other than the obvious advice on redeclaring a class in PHP. I even tried to change the class name in the mysqli.php file, but that just broke things even more.

Any advice or guidance would be appreciated.
Frank

Newbie

Posts

Joined
Mon Feb 06, 2012 7:35 pm

Post by vcabreu.py » Tue Jan 26, 2016 8:40 pm

Ello, mate.
Lets fix this with a simple gambiarra

File = system/database/mysqli.php

Code: Select all

<?php
if (!class_exists('MySQLi')) {
final class MySQLi[ code and more code............]

}
?>
The php function class_exists('class') check if the class is declared already, so is check if the class isn`t declared (!class_exists('MySQLi')) to declare it. I dont know if that is the best way to do it but it should prevent the class be declared twice.

:joker:

User avatar
Newbie

Posts

Joined
Thu Jan 14, 2016 12:30 am
Location - Americana | São Paulo | Brazil
Who is online

Users browsing this forum: No registered users and 37 guests