puponpup Posted January 8, 2009 Share Posted January 8, 2009 Hi all, I've written a script to read from an external XML file, but every time I run the script, I get a different amount of information. I've tried messing with (increasing/decreasing) the second parameter in fread() to no avail. I cut out everything unnecessary to create a simple test file. You can see the script running at: http://ariherstand.com/temp/test.php or just check out the code below: <html> <body> <?php $file = "http://feeds.artistdata.com/xml.shows/artist/AR-YX458DZO75EQACZ3/xml/future"; $fp = fopen($file, "r"); $data = fread($fp, 10000000); echo $data; ?> </body> </html> I know it's not ArtistData (the people serving up the xml feed), because I can go to their site - http://feeds.artistdata.com/xml.shows/artist/AR-YX458DZO75EQACZ3/xml/future - and it gives the same amount of info every time I refresh. Besides being sporadic, I also haven't had it give me the full amount of information yet. There should be something like 16 separate shows. Quote Link to comment https://forums.phpfreaks.com/topic/140016-fread-is-grabbing-sporadic-amounts-of-info/ Share on other sites More sharing options...
premiso Posted January 8, 2009 Share Posted January 8, 2009 Try this instead. <?php $data = file_get_contents("http://feeds.artistdata.com/xml.shows/artist/AR-YX458DZO75EQACZ3/xml/future"); echo $data; ?> And see what gets returned. Also view the source of that test.php page you have, the xml data is there, the issue is you are using <html> tags etc instead of proper XML tags. This will cause issues of feeds not displaying right. Quote Link to comment https://forums.phpfreaks.com/topic/140016-fread-is-grabbing-sporadic-amounts-of-info/#findComment-732550 Share on other sites More sharing options...
PFMaBiSmAd Posted January 8, 2009 Share Posted January 8, 2009 See example #3 in the manual - http://us2.php.net/fread Quote Link to comment https://forums.phpfreaks.com/topic/140016-fread-is-grabbing-sporadic-amounts-of-info/#findComment-732554 Share on other sites More sharing options...
puponpup Posted January 8, 2009 Author Share Posted January 8, 2009 Try this instead. <?php $data = file_get_contents("http://feeds.artistdata.com/xml.shows/artist/AR-YX458DZO75EQACZ3/xml/future"); echo $data; ?> Cool, that did the trick. Thanks! Also view the source of that test.php page you have, the xml data is there, the issue is you are using <html> tags etc instead of proper XML tags. This will cause issues of feeds not displaying right. Yeah, I had been viewing the source but it was never giving me enough separate shows. Your function did the trick, though. Yay! Quote Link to comment https://forums.phpfreaks.com/topic/140016-fread-is-grabbing-sporadic-amounts-of-info/#findComment-732558 Share on other sites More sharing options...
puponpup Posted January 8, 2009 Author Share Posted January 8, 2009 See example #3 in the manual - http://us2.php.net/fread Good to know, must have glanced over that in my frantic search to find what was wrong. Bookmarking now... Quote Link to comment https://forums.phpfreaks.com/topic/140016-fread-is-grabbing-sporadic-amounts-of-info/#findComment-732559 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.