-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a message when not able to connect to database #1845
Comments
What database connection type are you using? What error did you get? Can you add a screenshot please. |
MySQL, using mysql, the mysql_connect could not recognize the hostname because a fail on my server. This is what users see when this happens (http://hub.edirpedro.com.br/arquivos/mysql_connect_error.png). It's not a professional crash, look at the default theme beeing displayed. It needs to check database connection fully before start running the store, connection and database needs to be available here. |
You do not display errors on a live environment, disable them in the settings area for your store. Having them enabled is a security issue and is ONLY intended for development/ testing. If you disable then you will just get a white screen (handle that as you would like on your own store etc) - but you should enable error logging to the error.txt file under system/logs. You cannot handle every single issue that php can throw with a custom message - it would take far too long. |
Additionally, mysql_connect is being removed in PHP now, you need to use MySQLi engine. |
James, I think you didn't understand, the error exists, this option on Admin panel only works if database is available and this not apply here. What I'm telling is that there is no die() on the script if a database connection fails at startup and this do not depend of that option in Admin panel. I made this test:
If the connection uses old MySQL instead of MySQLi the results is like you see on the screenshot i provided before. |
James, I forgot to say, for MySQLi this is a security issue because it shows me the user and password on the message in Fatal Error |
Looking into it, this seems that it has already been resolved on the pending 1.5.6.5 release: https://github.com/opencart/opencart/blob/v1.5.6.x/upload/system/database/mysqli.php Apologies though as this had not been documented in the change log - which will be added now for future knowledge. As you mentioned the security concern is that the database details are exposed on a failed connect - that is what has been resolved but you will still get an error when trying to connect to a DB that is incorrect. |
@jamesallsup sorry to bother you, but here http://www.opencart.com/index.php?route=download/download there is no v.1.5.6.5 to download! Thanks |
@kanenas - Opencart (at least to my knowledge) is only on active development for versions 2.X+. You can download version 2.0.0.0 at the opencart downloads link. Best of luck! DS-MATT |
Today my database crashed and the store shows me a bunch of error messages and part of the default OC theme, something very weird to see. It needs an error message here and stop running when not able to make a connection. Like WordPress does when this happens "Error establishing a database connection".
The text was updated successfully, but these errors were encountered: