@get_headers

Discussion in 'PHP' started by MyVodaFone, Feb 6, 2013.

  1. #1
    My code below works when it wants?
    It seems to me something is firing too quickly...

    If someone has a minute to look over it, that would be great.

    include dirname(__FILE__) . "/db.php";
     
    $search_id = $_GET['id'];
     
    $q = mysql_query("SELECT download_url FROM searches WHERE search_id = '$search_id'") or die(mysql_error());
    $row = mysql_fetch_row($q);
    $download_url =  $row[0];
     
    $file_headers = @get_headers(urldecode($download_url));
                if ($file_headers[0] == 'HTTP/1.1 404 Not Found' || $file_headers[0] == 'HTTP/1.1 403 Forbidden' || $file_headers[0] == 'HTTP/1.1 301 Moved Permanently') {
                echo 'Thanks and well spotted, our system has deleted this file link from the database.';
                mysql_query("DELETE FROM searches WHERE search_id = '$search_id'") or die(mysql_error());
                } else {
                echo 'Hmmm...it seems as though this file link is a valid one and should play?<br /><br />Would you like to tell us more about the problem you are experiencing?<br /><br /> <a href="contactus.php">Contact Us</a>';
      } 
    PHP:
     
    MyVodaFone, Feb 6, 2013 IP
  2. shofstetter

    shofstetter Well-Known Member

    Messages:
    178
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    120
    #2
    you should also check if get_headers() returned false
     
    shofstetter, Feb 6, 2013 IP