Hiding PHP / MySQL error message

泄露秘密 提交于 2019-12-09 13:56:07

问题


I have a website based on X-Cart. It’s working fine. However, when I go to the address (manually accessing the link) www.mysite.com/"Xx<XaXaXXaXaX>xX I get this error message:

INVALID SQL: 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '",)' LIMIT 1' at line 1<br /><b><font color="darkred">SQL QUERY FAILURE:</font></b>SELECT xid FROM xcart_session_history WHERE ip = INET_ATON('165.193.42.141') AND host = '&quot;XxxXx';&quot;,)' LIMIT 1
INVALID SQL: 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';",)', 'e8bc1df13aab2c25c7560512a5029eb1')' at line 1<br /><b><font color="darkred">SQL QUERY FAILURE:</font></b>REPLACE INTO xcart_session_history (ip,host,xid) VALUES (INET_ATON('165.193.42.141'), '&quot;XxxXx';&quot;,)', 'e8bc1df13aab2c25c7560512a5029eb1')

I find this to be a vulnerability on my system because it reveals the table name and other details.

I would like to keep PHP/MYSQL from showing this message on the screen. How can I disable it?


回答1:


Set $debug_mode in config.php to 2

http://help.x-cart.com/index.php?title=X-Cart:Config.php#Correcting_debug_mode




回答2:


// Turn off all error reporting

error_reporting(0);

// Report all PHP errors

error_reporting(E_ALL);

// Report all PHP errors

error_reporting(-1);

use any of that one if you use database then select error_reporting(0)




回答3:


To turn off all error reporting:

error_reporting(0);

You should set it at top of some header file that is loaded across all pages.




回答4:


error_reporting(0); //is safer then modifying the config.php file



来源:https://stackoverflow.com/questions/11698434/hiding-php-mysql-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!