SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can someone tell me the best way to stop a php script from throwing out error messages if it can't work. I'm using a web fetching script which occasionally throws errors due to changes that are out of my control - ie changes on the fetched site.

    I've got a 'no headlines found' message which comes up if 'grab' fails, but it still throws error messages if something else is wrong.

    I want a total block on all error messages if anything doesn't work.

    Cheers
    <Edited by ChilliBoy on 12-15-2000 at 04:54 PM>

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can either put

    error_reporting(0);

    at the top of your script which would be the easiest this turns off errors for the whole script even parse errors.

    OR

    you an use an @ in front any function that you don't want errors to show
    ie
    @$fp = fopen("someurl");
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Putting a @ sign in front of the command should block the errors, say you wanna connect to a db, but don't want it to give you errors if it fails, you would use:

    @mysql_connect($site, $username, $password)

  4. #4
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers,

    This (error_reporting(0) looks like the baby!

    I can the (0) be changed to what you want??


    <Edited by ChilliBoy on 12-15-2000 at 06:11 PM>

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just be careful because like i said if you have a parse error it won't show it to you
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry Freddie,

    Just edited my post while you where posting:

    Can the (0) be changed to what you want??

    I'm not to worried about the errors not being reported. If the script is working OK initially and then things aren't coming up, I can quick remove the 'no error tag' to find out whats wrong. I was testing things out when it threw out an error and it messed up the whole page. - Can't have that happening.

    Cheers







  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes the default error reporting is 15 which means
    1+2+4+8

    1 = Fatal Errors
    2 = Warnings
    4 = Parse Errors
    8 = Notices

    So setting t0 7 would be turn on errors for Fatal Errors, Warnings and Parse Errors

    3 would be Fatal Errors and Warnings
    1 would just be fatala errors
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

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