Computing.Net > Forums > Web Development > suppress PHP, mysql warnings

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

suppress PHP, mysql warnings

Reply to Message Icon

Name: Don Arnett
Date: December 19, 2004 at 22:01:20 Pacific
OS: linux
CPU/Ram: na
Comment:

I'm using PHP and mysql. I'm having a problem figuring out how to handle mysql errors and warnings.

For example, if I have trouble connecting to the database, I know how to check the return from the mysql_connect() function and go on from there to build my page, but php still displays warning messages on the webpage. So the warnings get mixed in with my text.

Is there a way to change this. Maybe a setting in php to not display warning message. I don't want the warning messages, just let me check the return codes!!

Be sure to come back and let us know if our suggestions helped!



Sponsored Link
Ads by Google

Response Number 1
Name: Khalid
Date: December 19, 2004 at 23:28:42 Pacific
Reply:

Look in your php.ini-file for the section which I copied and pasted below.

Warnings can be surpressed, but fatal errors (like parsing errors) cannot and will crash your script anyway. It is very hard to write good code if you have turned off all the errors, so I suggest you look for a different approach (i.e. post parts of the script wich causes the errors in this forum)

Good luck.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; error_reporting is a bit-field. Or each number up to get desired error
; reporting level
; E_ALL - All errors and warnings
; E_ERROR - fatal run-time errors
; E_WARNING - run-time warnings (non-fatal errors)
; E_PARSE - compile-time parse errors
; E_NOTICE - run-time notices (these are warnings which often result
; from a bug in your code, but it's possible that it was
; intentional (e.g., using an uninitialized variable and
; relying on the fact it's automatically initialized to an
; empty string)
; E_CORE_ERROR - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's
; initial startup
; E_COMPILE_ERROR - fatal compile-time errors
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
; E_USER_ERROR - user-generated error message
; E_USER_WARNING - user-generated warning message
; E_USER_NOTICE - user-generated notice message
;
; Examples:
;
; - Show all errors, except for notices
;
;error_reporting = E_ALL & ~E_NOTICE
;
; - Show only errors
;
;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
;
; - Show all errors except for notices
;
error_reporting = E_ALL; display all errors, warnings and notices


0

Response Number 2
Name: Don Arnett
Date: December 20, 2004 at 07:22:24 Pacific
Reply:

Thanks for the response. I apparently didn't explain myself well enough.

I'm not worried about syntax errors etc. I can write the code so that there are no errors when everything works, but what about if the DB is down when someone accesses the page.

I know how to check the return codes and code my page so that I can display the appropriate messages, etc., but php is also displaying warning messages that appear on my page. I don't want to turn off error return codes, I just want to set php to not display messages. Give me return codes but don't write on my page!!!

Be sure to come back and let us know if our suggestions helped!


0

Response Number 3
Name: junfrales
Date: December 21, 2004 at 11:21:34 Pacific
Reply:

use @ sign in front of function u wanna suppress and it will do it.

ex.. if (@function) { blah }

Diff between M$ Win and a Virus?
A virus always works


0

Response Number 4
Name: Don Arnett
Date: December 24, 2004 at 10:41:02 Pacific
Reply:

Thanks guys, both worked.

Again, the point wasn't to ignore the warnings, but to let my code decide what appears on the screen and not have PHP printing error messages to the screen.


Be sure to come back and let us know if our suggestions helped!


0

Response Number 5
Name: Don Arnett
Date: December 24, 2004 at 10:59:38 Pacific
Reply:

I also found the

display_errors = Off/On

setting in php.ini. I set it to off and the warning messages to appear on the screen. Just what I wanted. The 'error_reporting' would let you have finer control of which error messages appear.

Be sure to come back and let us know if our suggestions helped!


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: suppress PHP, mysql warnings

How do I setup PHP & MySQL on XP www.computing.net/answers/webdevel/how-do-i-setup-php-amp-mysql-on-xp/122.html

PHP, MySQL, phpMyAdmin www.computing.net/answers/webdevel/php-mysql-phpmyadmin/1590.html

php/mysql database www.computing.net/answers/webdevel/phpmysql-database/2542.html