avoid error output

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I've a file wich must answer a request. For this my file must generate an  
XML output.

That's work fine but sometimes I get a wrong mysql query. In this case, I've  
to manage the output message. Problem: the mysql error message is shown, so  
the answer will have the mysql error then the XML output, and this don't  
works for the "reading" script.

How to avoid tho show the mysql error when any ? I can't modify php.ini.

Thanks for answer.


Re: avoid error output

You can either append an "@" to the function, for example;
@mysql_connect, or turn off error reporting for the whole script by
adding these two lines to the top of your script.

ini_set('display_errors', 0);

Re: avoid error output


Quoted text here. Click to load it

It would be better to check what caused the error and fix/handle it.


Re: avoid error output

That's true and i totally agree with you but in this case it doesn't
seem the app is broken. I guess it's broken in the sense that the
programmer isn't checking if a query result is valid. Just telling them
what they want to know. If it were my script i'd echo something useful
when a query result failed.

Re: avoid error output

Quoted text here. Click to load it

Thanks for your answers.
I'm actually "answering" a remote script with XML code. id there is anything  
else than xml datas (case of a mysql error or anything else), then the  
script fails to create a good XML output and the answer is wrong.

I've to manage if the mysql server fails (I do check and return an error in  
the XML message) instead of a message on the screen.

Thanks for your answer !


Site Timeline