SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    May 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help for a *very* simple script!

    Hello all,

    A PHP guru and myself (NOT a guru!) are trying to get a very simple script running. It runs great on his Linux-based apache server, but does not run on mine (Apache 2.2 on FreeBSD9) or the actual server where it will live one day! It simply pulls one stat (a listener count) from a Shoutcast server's XML stats page and returns a single number.

    Code:
    <?php 
    $getstats = file_get_contents('http://myserver.com:8000/stats?sid=1');
    $stats = simplexml_load_string($getstats);
    echo $stats->UNIQUELISTENERS;
    ?>
    Extremely simple as you can see ... no problem seeing the XML page from the Shoutcast server, but for some reason my Apache/PHP-5.3.8 server doesn't like it, and the test server doesn't either. The two of us have been banging our heads for weeks about this. There are other much more complex scripts on the same site, and the server has no problem with those. Any ideas?

    Thanks,
    Steve

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Firewall? Check allow_url_fopen too. Add error_reporting(-1); ini_set('display_errors', true); just before it executes too.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Member
    Join Date
    May 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your quick response. I did add those lines to debug it, and the error I get is:

    Notice: Trying to get property of non-object in /home/******/testbed/listeners.php on line 6

    And line 6 is the last line:
    echo $stats->UNIQUELISTENERS;

    Also, phpinfo shows allow_url_fopen is ON.

    Thanks,
    Steve

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    What does var_dump($getstats); give you? false?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Member
    Join Date
    May 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, i think so ... it gives this result:

    string(0) ""

    Obviously a problem


Tags for this Thread

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
  •