473,834 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file_get_conten ts outputs nothing

Hi everyone,

The output of

echo file_get_conten ts("http://watchout4snakes .com/creativitytools/
RandomWord/RandomWordPlus. aspx");

leaves the browser empty.. no error messages, nothing.

Why is this occurring?

Thanks

Taras

Oct 25 '07 #1
6 6954
Taras_96 <ta******@gmail .comwrote in news:1193323567 .561939.158410
@y27g2000pre.go oglegroups.com:
Hi everyone,

The output of

echo file_get_conten ts("http://watchout4snakes .com/creativitytools/
RandomWord/RandomWordPlus. aspx");

leaves the browser empty.. no error messages, nothing.

Why is this occurring?
presumably you have an error somewhere and error_reporting is set to off.
Oct 25 '07 #2
On Oct 25, 11:40 pm, Good Man <he...@letsgo.c omwrote:
Taras_96 <taras...@gmail .comwrote in news:1193323567 .561939.158410
@y27g2000pre.go oglegroups.com:
Hi everyone,
The output of
echo file_get_conten ts("http://watchout4snakes .com/creativitytools/
RandomWord/RandomWordPlus. aspx");
leaves the browser empty.. no error messages, nothing.
Why is this occurring?

presumably you have an error somewhere and error_reporting is set to off.
>From my php.ini
error_reporting = E_ALL|E_STRICT

; Print out errors (as a part of the output). For production web
sites,
; you're strongly encouraged to turn this feature off, and use error
logging
; instead (see below). Keeping display_errors enabled on a production
web site
; may reveal security information to end users, such as file paths on
your Web
; server, your database schema or other information.
display_errors = On
Oct 25 '07 #3
Taras_96 <ta******@gmail .comwrote in
news:11******** *************@k 35g2000prh.goog legroups.com:
On Oct 25, 11:40 pm, Good Man <he...@letsgo.c omwrote:
>Taras_96 <taras...@gmail .comwrote in news:1193323567 .561939.158410
@y27g2000pre.g ooglegroups.com :
Hi everyone,
The output of
echo file_get_conten ts("http://watchout4snakes .com/creativitytools/
RandomWord/RandomWordPlus. aspx");
leaves the browser empty.. no error messages, nothing.
Why is this occurring?
This is on the manual page for file_get_conten ts, is this why? do you have
fopen wrappers enabled?
You can use a URL as a filename with this function if the fopen wrappers
have been enabled. See fopen() for more details on how to specify the
filename and Appendix O, List of Supported Protocols/Wrappers for a list of
supported URL protocols.

http://ca.php.net/file_get_contents
Oct 25 '07 #4
On Thu, 25 Oct 2007 16:46:07 +0200, Taras_96 <ta******@gmail .comwrote:
Hi everyone,

The output of

echo file_get_conten ts("http://watchout4snakes .com/creativitytools/
RandomWord/RandomWordPlus. aspx");

leaves the browser empty.. no error messages, nothing.

Why is this occurring?
It's a badly designed website/server, which apparently applies browser
sniffing of some sort. You'll have to mimique a common UA with for
instance CURL to get it to output anything. This works:

<?php
$ch = curl_init();

curl_setopt($ch , CURLOPT_URL,
"http://watchout4snakes .com/creativitytools/RandomWord/RandomWordPlus. aspx");
curl_setopt($ch ,CURLOPT_USERAG ENT,'Mozilla/5.0 (Windows; U; Windows NT
5.2; en-GB; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7');

curl_exec($ch);
curl_close($ch) ;
?>

... without setting the CURLOPT_USERAGE NT the site indeed outputs nothing..
--
Rik Wasmus
Oct 25 '07 #5
Okay I just tried this with readfile.
$path = 'http://watchout4snakes .com/creativitytools/RandomWord/
RandomWordPlus. aspx';

echo readfile($path) ;
Now, readfile returns the number of bytes read from the file or false
on failure and this outputs '0'.

This leads me to believe that the problem is something to do with the
aspx page not the php code.

Oct 25 '07 #6
On Oct 26, 3:02 am, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Thu, 25 Oct 2007 16:46:07 +0200, Taras_96 <taras...@gmail .comwrote:
Hi everyone,
The output of
echo file_get_conten ts("http://watchout4snakes .com/creativitytools/
RandomWord/RandomWordPlus. aspx");
leaves the browser empty.. no error messages, nothing.
Why is this occurring?

It's a badly designed website/server, which apparently applies browser
sniffing of some sort. You'll have to mimique a common UA with for
instance CURL to get it to output anything. This works:

<?php
$ch = curl_init();

curl_setopt($ch , CURLOPT_URL,
"http://watchout4snakes .com/creativitytools/RandomWord/RandomWordPlus. ...");
curl_setopt($ch ,CURLOPT_USERAG ENT,'Mozilla/5.0 (Windows; U; Windows NT
5.2; en-GB; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7');

curl_exec($ch);
curl_close($ch) ;
?>

.. without setting the CURLOPT_USERAGE NT the site indeed outputs nothing.
--
Rik Wasmus
Yep, that would do the trick :D

Thanks all for your suggestions

Taras

Oct 26 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4217
by: Rob | last post by:
for some reason i keep getting : Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/rob/www/php/filegetcontents2.php on line 3 Warning: file_get_contents(http://folding.stanford.edu/teamstats/team92.txt): failed to open stream: Resource temporarily unavailable in /home/rob/www/php/filegetcontents2.php on line 3
4
6449
by: Sarah Haff | last post by:
Hi, What would be minimilistic XSLT that does "nothing" (no transformation) to the given XML content. Thank you. Sarah Haff
1
5049
by: jjainschigg | last post by:
I'm running PHP 5 on a shared VPS. I have a couple little apps that are using file_get_contents() and readfile() for various kinds of (what should be) low-overhead, fast outbound accesses ... that is, I'm handing URLencoded arguments to a couple fast servers and grabbing small patches of XML in return. When I enter these URL+argument strings in a browser (with the caches turned off), I get effectively instant responses -- so the remote...
5
23040
by: howa | last post by:
are there any advantage in replacing all fread() operations with file_get_contents() ? i.e. file_get_contents("/usr/local/something.txt") VS $filename = "/usr/local/something.txt";
4
2743
by: Aetherweb | last post by:
This is probably really obvious, sorry, been a long day... I'm wanting to create a PHP file which is a template for an email, and read the file into a string, ready to send out using my email functions... but I want to be able to get the PHP file to be server processed so that its content is created on the fly. Eg in pseudo code, what I want to do is this: 1$email_param1 = "my email param 1";
9
21014
by: howa | last post by:
Target: To fetch a file using PHP and send to user Method 1: echo file_get_contents( $file_path ); Method 2: readfile( $file_path );
5
21375
by: mmarlow | last post by:
Hi all, I'm trying to get the contents of a file from a URL using file_get_contents() or file(). It doesn't work, it eventually just times out. It used to display a 'failed to open file' message but now returns nothing at all. - it works with any site that's not on our server, eg: google.com - allow_url_fopen is ON (proven with the above test) - we have two load balanced servers with identical settings, could this be an issue?
0
5020
by: pac1250 | last post by:
Hi, I am searching how to solve a problem and I dont find it :( I want to access a page from a script behind a proxy : (my script) <-(a proxy with authentification) <-(https serveur with authentification) -----------------------------------------------------------------
6
3642
by: Pheddy | last post by:
Hey i tried this code to get the country and IP via PHP (from: http://roshanbh.com.np/2008/07/getting-country-city-name-from-ip-address-in-php.html) function countryCityFromIP($ipAddr) { //function to find country and city from IP address //Developed by Roshan Bhattarai http://roshanbh.com.np //verify the IP address for the ip2long($ipAddr)== -1 || ip2long($ipAddr) === false ? trigger_error("Invalid IP", E_USER_ERROR) : "";...
0
9796
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10503
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10544
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10214
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3079
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.