SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help Me With This, Please

    There are 2 images that are being changed every couple of hours... Not on my site!
    I need a code that will write in a certain page in my site a certain sentance when the image is online right now or a different sentance when its not online...

    Can you help me please??
    Last edited by sleepingdanny; Jan 27, 2003 at 12:35.

  2. #2
    SitePoint Addict The Mog's Avatar
    Join Date
    Dec 2002
    Location
    Manchester UK
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    whats the url of the image, i have a idea but i want to try it first

  3. #3
    SitePoint Addict The Mog's Avatar
    Join Date
    Dec 2002
    Location
    Manchester UK
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This will do the trick

    PHP Code:
    <?php

    $file 
    = @fopen("http://www.somedomain.com/image.gif","r");
    if (
    $file){
       echo 
    "The image is online";
     }else{
       echo 
    "The image is offline";
    }
    ?>
    K-

  4. #4
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks I'll try it!

  5. #5
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried it, but the code that you told me is looking for the image in the site and if the image is uploaded it will write the image is online...

    But I needed a code that will tell me if the image is exists in a certain page right now or a different image is set right now and not if the image is uploaded or not...

    But thanks anyway!!

  6. #6
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Try -
    PHP Code:
    if ( file_exists('http://www.site.com/image.gif') )
    {
       echo 
    'Whooppee!!!!!';
    }
    else
    {
       echo 
    'Bugger!!!';


  7. #7
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its almost the same code as the first one, it just uses "file_exists()"...

  8. #8
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You know what... How can I do this??

    I want to know if this image => 123.gif
    in this page => 123.php

    Can you give me a code for this please??

  9. #9
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    OK, you could try reading the HTML file and finding which image is loaded.
    PHP Code:
    $file file('http://www.site.com/image.html');

    // say the <IMG> tag you want is on line 48 of the file
    echo $file[47] . '<br />'// note 1 number less 
    You could parse the output to find the exact filename but I'm too tired to post all that tonight but you can go read up on substr() and strpos() at PHP.net which are the easiest functions to parse the file.

    However, if your really lucky, the file might be written in XML which means you can use PHP's XML functions.

  10. #10
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks!!!!!!1


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
  •