SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast Misery's Avatar
    Join Date
    Aug 2003
    Location
    England
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how do i stop an error showing?

    Lo lo.
    Im using a winamp broadcast script (displays track, bitrate etc, but i modified it to say "server online" or "offline") but when its offfline I get an ugly :

    Warning: fsockopen(): unable to connect to guirockcast.no-ip.com:4800 in /home/shook/public_html/broadkast/index.php on line 165
    then it displays my "server offline"

    Now my actual code i thought was fine and wouldnt show the error does
    PHP Code:
    $c1 fsockopen ($ip$port$errno$errstr2); 
    if (!
    $c1) {  echo "<font color=red><B>server offline</b></font><BR><br>"; } 
    else {  echo 
    "<font color=green><B>server online</b></font><br><BR>"; } 
    How can i make it so it just shows "Server Offline"? a friend said something about "catching errors" but php.net is no help, it always confuses me
    <---Noob


  2. #2
    SitePoint Addict shad0w's Avatar
    Join Date
    Aug 2003
    Location
    PA
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $c1 = @fsockopen ($ip$port$errno$errstr2);
    if (!
    $c1) {  echo "<font color=red><B>server offline</b></font><BR><br>"; }
    else {  echo 
    "<font color=green><B>server online</b></font><br><BR>"; } 

    Putting the @ symbol in front of any function will supress the error message if it encounters an error.

  3. #3
    SitePoint Enthusiast Misery's Avatar
    Join Date
    Aug 2003
    Location
    England
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks works 100%!!!!
    <---Noob



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
  •