473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Urgent fopen question

When I use fopen on the URL:
fopen("http://home.pchome.com.tw/world/qoo4ko/110.jpg";, "r")
I would get the following error message:

-----------Error Message------------
Warning: fopen(): Circular redirect, aborting.
Warning: fopen(http://home.pchome.com.tw/world/qoo4ko/110.jpg): failed
to open stream: Permission denied
------------------------------------

But when I use HTML (<img src="<?=$URL?>" alt="">), to display it, it
does display on the screen.

How come fopen cannot open certain URLs while <img> can display them.
Does anyone have any idea why this happens?

I'm try to use fopen to check if a link is broken. If anyone has a
workaround solution, it would be great, too.

Thanks very much.
Jul 17 '05 #1
3 3655
Ming wrote:
When I use fopen on the URL:
fopen("http://home.pchome.com.tw/world/qoo4ko/110.jpg";, "r") Does it work any better when you put the semicolon at the end instead of
the middle of the line?

Steve I would get the following error message:

-----------Error Message------------
Warning: fopen(): Circular redirect, aborting.
Warning: fopen(http://home.pchome.com.tw/world/qoo4ko/110.jpg): failed
to open stream: Permission denied
------------------------------------

But when I use HTML (<img src="<?=$URL?>" alt="">), to display it, it
does display on the screen.

How come fopen cannot open certain URLs while <img> can display them.
Does anyone have any idea why this happens?

I'm try to use fopen to check if a link is broken. If anyone has a
workaround solution, it would be great, too.

Thanks very much.

Jul 17 '05 #2
Ming wrote:
When I use fopen on the URL:
fopen("http://home.pchome.com.tw/world/qoo4ko/110.jpg";, "r")
I would get the following error message:

-----------Error Message------------
Warning: fopen(): Circular redirect, aborting.
Warning: fopen(http://home.pchome.com.tw/world/qoo4ko/110.jpg): failed
to open stream: Permission denied
------------------------------------


Never seen this with fopen(...); but I have seen it in Konqueror (a web
browser) when the page issues a redirect to it's own URL (other browsers
happily follow the redirection).

Try getting the headers from http://home.pchome.com.tw/world/qoo4ko/110.jpg
and see if it returns a 200 or something else.

HTH

C.

Jul 17 '05 #3
Ming wrote:
When I use fopen on the URL:
fopen("http://home.pchome.com.tw/world/qoo4ko/110.jpg";, "r")
I would get the following error message:

-----------Error Message------------
Warning: fopen(): Circular redirect, aborting.
Warning: fopen(http://home.pchome.com.tw/world/qoo4ko/110.jpg): failed
to open stream: Permission denied
------------------------------------
That's right. It's a 'circular redirect', or an infinite
loop. HTTP/1.0, the previous HTTP spec, said that 'a user
agent should never automatically redirect a request more
than 5 times, since such redirections usually indicate an
infinite loop'; HTTP/1.1 says that 'a client SHOULD detect
infinite redirection loops, since such loops generate
network traffic for each redirection'. Fopen apparently
follows this advice.
But when I use HTML (<img src="<?=$URL?>" alt="">), to display it, it
does display on the screen.

How come fopen cannot open certain URLs while <img> can display them.
Does anyone have any idea why this happens?
Smells awfully like browser sniffing to me. The response
differs depending on the request's User-Agent header. If
User-Agent contains 'Mozilla', for instance, the status code
is 200, OK; with no User-Agent header, it's 302 -- a
temporary redirection.
I'm try to use fopen to check if a link is broken. If anyone has a
workaround solution, it would be great, too.


Use fsockopen. Send a HEAD request and read the status code
from the first line of the response.

--
Jock
Jul 17 '05 #4

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

Similar topics

4
by: Robert Schott | last post by:
Hi .. this is for sure the 1k question on fopen but maybe can someone tell me this weird staff if i'm writing: $H = fopen($value,"r"); while(!feof($H)) { $string = fgets($H,1024); .... .......
4
by: Carl Harris | last post by:
I am trying to write some code to: 1.Prompt a user for filenames 2.Open the files 3.Convert my plain text into a cipher text array/string bear in mind I am a novice! I have wriiten some code...
4
by: Imran | last post by:
Hello All Am trying to read a huge txt file and write to a file back. pls see the code int main() { char* pData;
10
by: Longfellow | last post by:
Newbie here... My reading of the description of fopen() led me to expect that, with mode as "w", it would create a file if it did not exist. Checked the FAQ and did not see this question...
2
by: Meena | last post by:
Hi all, I have a problem with Apache and Windows I tried to include a php script that i downloaded to get me real time money exchange rates, but it uses fopen() function and i get this error:...
6
by: rfhurley | last post by:
I'm a newbie at this... I'm trying to run a PHP script from the W3C PHP tutorial, and the example shows the following code: <html> <body> <?php $file=fopen("welcome.txt","r"); ?>
10
by: Julia | last post by:
Hi, there, I am trying to append a binary file by using: FILE *strean; stream = fopen( "c:\temp.dat", "ba+" )); Is there a way that I can check if the file exists or not before fopen,...
0
by: chikhalepankaj | last post by:
Hi guys, I have a problem in reading a file content which r in tab separated value formate eg. MODULE AD0 AD1 AD2 AD3 AD4 AD5 AD6 AD7 4011 ...
14
by: Umesh | last post by:
CoffeeVendor is a program, which simulate a coffee machine. The coffee machine serves coffee with sugar and creamer for Rs.10/- and Rs.6/- without sugar and creamer (black coffee). The coffee...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.