1

I have tried all the solutions over the internet but still i am not able to solve it.

Problem- Opencart Displaying Php/MySql Errors (which also shows the password used to connect to mysql)

When Opencart faces any problem in connecting to MySql Database or due to too many connections php is unable to connect to database a error is displayed in the following format.

Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'indiaran_admin'@'localhost' (using password: YES) in /home3/indiaran/public_html/system/database/mysqli.php on line 6

Fatal error: Uncaught exception 'ErrorException' with message 'Error: Could not make a database link' in /home3/indiaran/public_html/system/database/mysqli.php:9 Stack trace:#0 /home3/indiaran/public_html/vqmod/vqcache/vq2-system_library_db.php(13): DBMySQLi->__construct('localhost', 'indiaran_admin', 'PASSWORD', 'indiaran_db') #1 /home3/indiaran/public_html/index.php(44): DB->__construct('mysqli', 'localhost', 'indiaran_admin', 'PASSWORD', 'indiaran_db') #2 {main} thrown in /home3/indiaran/public_html/system/database/mysqli.php on line 9

Expected Solutions:- (any would do)

  • Opencart Stops Displaying Any error Mysql/php
  • Error is Displayed without showing my database id and password.
  • Any Solution which stops displaying all the error (including the mysqli connect errors)

Solutions Tried:-

First

php.ini has
display_errors = Off;
error_reporting = 0;

htaccess has
php_value error_reporting 0

Second

There is a setting within the OpenCart dashboard that allows you to turn on (or off) error reporting and logging.    
Log into your dashboard
    In the menu, go to "System" and select "Settings"
    In the list of stores, click "Edit" for your store
    Click the "Server" tab.
    Scroll down, and there's two settings:
    a. Log Errors - set this as desired
    b. Display Errors - set this to "No"

Third

Commenting Out set_error_handler('error_handler'); in index.php

Fourth

Using Php Try-Catch Phrase, which i dont know exactly how to use in opencart.

Hope i am able to explain myself and someone would be able to helpme.

PS:- My Website is Hosted with Hostgator as a Shared Hosting.

Links to Similar problems which were unable to solve my problem.

http://stackoverflow.com/questions/16935473/cant-disable-error-reporting-in-opencart-php

http://stackoverflow.com/questions/5040048/php-mysql-too-many-connections-to-database-error

http://stackoverflow.com/questions/25957024/warning-mysqlimysqli-mysqli-mysqli-08004-1040-too-many-connections-in

http://stackoverflow.com/questions/28591394/mysqli-connect-error-shows-password/28591455#28591455
Angad Arora
  • 719
  • 10
  • 25
  • What is the reason for asking again if you already accepted an answer for your question regarding the same topic here: https://stackoverflow.com/questions/28591394/mysqli-connect-error-shows-password ??? – shadyyx Feb 23 '15 at 13:49
  • I accepted that answer because that helped me solve the problem everywhere but not when it comes to opencart, because when it comes to opencart nothing seems to work :/ – Angad Arora Feb 24 '15 at 05:55

1 Answers1

0

Your First Solution is correct and should do the needful BUT any changes done in php.ini would come into action after you reboot your Server (99% of the times, as per my experience).

I understand that you are currently using a shared server and it would not be possible for you to reboot the server so to overcome this issue I used PHP Rintime Configuration (PHPRC) when I faced this similar issue with Dreamhost Web Hosting Provider.

You can also contact your hosting provider to know how to implement PHPRC. If you want to see how it is done in Dreamhost, here is the link:

PHPRC in Dreamhost.

nik2702
  • 93
  • 1
  • 2
  • 8