Page 1 of 1

PHP Default Errors- How do I avoid showing these errors?

Posted: Sun Sep 03, 2006 2:34 pm
by danselstudios
Hey PHP Devs,

This is one of the most recent errors I've come across:
Warning: copy(images/6.jpg) [function.copy]: failed to create stream: Permission denied in c:\websites\nickyscott120\nickyscott.com\cpanel\cpanel.php on line 19

An earlier error was about not being able to connect to my MySQL database.
Anyway, these problems of course were fixed. Now when these types of errors occur the result is white blank page with the exception of the ""Warning: copy....failed to create stream: c:..\cpanel.php on LINE 19."" message.

How do i prevent this default php error page from showing up and echo a custom error page.

Right Now I have something like this:

Code: Select all

$link = mysql_connect( $server, $loginame, $loginpass );
if( $link ){
         // do something;
}else{
        // $errors[] = 'Could not connect to host.';
}
Thanks in advance, Daniel M.

Posted: Sun Sep 03, 2006 2:39 pm
by toasty2
You could do

Code: Select all

if (!<stuff goes here>)
{
// error stuff
}
The ! means "not", so you're saying if not <stuff> then do error stuff

Posted: Sun Sep 03, 2006 3:19 pm
by jayshields
That will still throw notices/warnings/errors if necessary. Try using @ before your function calls, although it's bad practice IMHO. What's wrong with the default PHP errors anyway?

Posted: Sun Sep 03, 2006 3:53 pm
by feyd
Proper preparative execution and handling is the general "good" practice, as already mentioned.

set_error_handler() may be of interest too.

Posted: Sun Sep 03, 2006 4:21 pm
by danselstudios
Well the default php error messages are just plain too long and UGLY.
So I'd like to handle the error messages myself so i may customize them to fit my website style.

I'll try set_error_handler() and @ before function calls.

thanks

Posted: Sun Sep 03, 2006 4:32 pm
by danselstudios
jayshields or anyone,,, may you tell me a good website where i can find a glossary for stuff like the @ or . or -> or =>

or perhaps the name of the class or category where these things belong-thanks

Posted: Sun Sep 03, 2006 4:38 pm
by Christopher
danselstudios wrote:jayshields or anyone,,, may you tell me a good website where i can find a glossary for stuff like the @ or . or -> or =>

or perhaps the name of the class or category where these things belong-thanks
Uhhh ... http://www.php.net/manual/

Posted: Sun Sep 03, 2006 5:49 pm
by danselstudios
I can't anything on @ or => at php.net...I go there for everything else.

Posted: Sun Sep 03, 2006 5:56 pm
by feyd