File Get contents not working - any ideas why?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

File Get contents not working - any ideas why?

Post by simonmlewis »

We have a really bad problem that is affecting multiple websites.

Perhaps someone can shed light on it.

http://www.remoteprice.com/data.asp?sto ... M27&type=2
If you visit this URL, it probably open a page with two lines of code, one that says 68 I think.

But if you put this into html/php:

Code: Select all

<?php
$romanstock = "http://www.remoteprice.com/data.asp?storeid=44175&itemcode=M27&type=2";
      $contentsstock = file_get_contents($romanstock);
      preg_match('/var cText = \'([0-9]+)\'/', $contentsstock, $matches);
      echo "$matches[1]";
      echo "$contentstock";
            ?>
It should show the result on screen. But doesn't. At the moment we think it could be down to the servers it is passing through, but when someone checks the URL on it's own and that works, we dont know why the file_get_contents doesn't.

Could one of the companies in the route of data, be blocking it ???
The companies are Cloudflare and Claranet.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: File Get contents not working - any ideas why?

Post by Celauran »

Works fine for me. What do you get if you var_dump($contentsstock)?
Post Reply