Page 1 of 1

Cannot redeclare class MySQLi in mysqli.php

Posted: Sun Jan 24, 2016 1:27 am
by frankjreda
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

Re: Cannot redeclare class MySQLi in mysqli.php

Posted: Tue Jan 26, 2016 8:40 pm
by vcabreu.py
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: