Results 1 to 4 of 4

Thread: make error page in php if sql error?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    448

    make error page in php if sql error?

    How would I go about saying if there is any php errors it doesnt load that page. It just loads the error page. I was thinking that i have a page called error.php it would detect if there are any errors . I would just include error.php to every page. Does anyone think they can help me out with this? If it doesnt make any sence just ask ill try to explain it differently. Thanks!

    edit: Im sorry i ment to say if there was a MySQL error. Because I would like it to be like vBulletin how if it can not connect to the database it loads that page that says so, and to contact the admin. If you can help me with this that would be great.
    Last edited by Muk108; Jan 10th, 2003 at 09:06 PM.

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    you have to set error_reporting to 0 I beleive then you have to log the loading process, so it is does have an error it will stop loading. you can't just stop at the beginning as the pages starts to load and recieves the error you will have half the page loaded.

    also I believe there is a setting in the ini file that will report all errors to a log file without doing any code.

    you will also have to make your own error catching function.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    448
    ok, Well I think I asked the wrong thing. I should have said if there where any MySQL errors like it couldnt connect to the database then it loads a different page. Could that be done?

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    you could try this

    $start = mysql_query($query_string);
    if (!$start){
    header ("Location: page.php");
    }


    but you canot echo anything before that to the browser or you will get an error. you could use an include if you wanted to.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width