473,485 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

fopen on an URL with parameters

Hi, could anybody give me some help with the following:

I'm trying to open a remote URL to be able to access it's contents:

$fp = fopen("http://www.google.nl/search?hl=nl&ie=UTF-8&oe=UTF-8&q=%22witte+zwanen%22,"r");

However, when I try to run this script. $fp returns false, and a warning "Result too large" is displayed.
This only occurs with urls that have any kind of parameters in them. If I open a random URL which doesn't have any parameters,
everything works fine, whatever size the requested file may be, so I don't think the warning is because the returned result
is too large, but that the problem lies in the specification of the URL.

Is there anybody who knows how to make it work?

Thanks in advance!

Daniel.
ds******@cs.vu.nl

Jul 17 '05 #1
5 7833
"dschreij" <ds******@cs.vu.nl> wrote in message
news:c0**********@star.cs.vu.nl...
Hi, could anybody give me some help with the following:

I'm trying to open a remote URL to be able to access it's contents:

$fp = fopen("http://www.google.nl/search?hl=nl&ie=UTF-8&oe=UTF-8&q=%22witte+zwanen%
22,"r");
However, when I try to run this script. $fp returns false, and a warning

"Result too large" is displayed.

The closing quote is missing from the URL. You might also look into using
something like htmlspecialchars() to properly encode the query-string chars.
Finally, if this is a real-life example and intended for others to use,
consider stripping out the "&ie=UTF-8&oe=UTF-8" as they indicate the detected
charset of Internet Explorer and Outlook Express, which might not even exist
on the user's computer.
Jul 17 '05 #2
dschreij wrote:
$fp = fopen("http://www.google.nl/search?hl=nl&ie=UTF-8&oe=UTF-8&q=%22witte+zwanen%22,"r");


You're missing a quote there!

Have you tried replacing "&" by "&amp;"?
Works fine both ways here.
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3
Pedro Graca wrote:
dschreij wrote:
$fp = fopen("http://www.google.nl/search?hl=nl&ie=UTF-
8&oe=UTF-8&q=%22witte+zwanen%22","r");

As has been pointed out, encode the query component. Use
rawurlencode. At the moment, that's not a valid URI, and if its
first parameter begins with "scheme://", fopen expects an URL. The
plus sign is a reserved character in the query component. You'd have
to URL encode it: %2b.
Have you tried replacing "&" by "&amp;"?


Yes. It connects, as you'd expect, but won't return the same result
because the parameters are different. HTML entity references should
have no meaning here.

--
Jock
Jul 17 '05 #4
John Dunlop wrote:
The plus sign is a reserved character in the query component. You'd
have to URL encode it: %2b.


If that's meant to be a space, encode it with %20. The plus sign as
a space is specific to form processing; in particular, it is used in
the application/x-www-form-urlencoded media type.

--
Jock
Jul 17 '05 #5
I tried echo
file_get_contents("http://www.google.nl/search?hl=nl&ie=UTF-8&oe=UTF-8&q=%22
witte+zwanen%22"); and it worked fine. What version of PHP do you have?

Uzytkownik "dschreij" <ds******@cs.vu.nl> napisal w wiadomosci
news:c0**********@star.cs.vu.nl...
Hi, could anybody give me some help with the following:

I'm trying to open a remote URL to be able to access it's contents:

$fp = fopen("http://www.google.nl/search?hl=nl&ie=UTF-8&oe=UTF-8&q=%22witte+zwanen
%22,"r");
However, when I try to run this script. $fp returns false, and a warning "Result too large" is displayed. This only occurs with urls that have any kind of parameters in them. If I open a random URL which doesn't have any parameters, everything works fine, whatever size the requested file may be, so I don't think the warning is because the returned result is too large, but that the problem lies in the specification of the URL.

Is there anybody who knows how to make it work?

Thanks in advance!

Daniel.
ds******@cs.vu.nl

Jul 17 '05 #6

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

Similar topics

2
25121
by: Candy Robinson | last post by:
I have created a directory for the path name I use for a UTL_FILE.OPEN call, but when I run my call I get error ORA-29280 invalid directory path. What am I failing to do? Thanks for your help, ...
19
31601
by: Taras | last post by:
I wrote following program: #include <stdio.h> main() { FILE *file; file=fopen(d:\readme.txt,"r"); if (file==NULL)
9
1477
by: soumen | last post by:
Hi, I'm a newbie compiling the following program on Sun Solaris platform for reading data from a file. The code commented as "/* WORKING */" is working (!). But in the current form of...
4
2860
by: lucyachammond | last post by:
I have a 3rd party real-estate website written in php. I would like to call an asp script on a separate webserver each time a new real-estate item is added to the database on the php site. The...
1
5530
by: nebelraabe | last post by:
hi there. I encountered a problem when i wanted to open a file which name i read from an ini file. FILE *fopen(const char *filename, const char *mode); as far as i know, fopen( ) accepts only...
4
1886
by: Bob Bedford | last post by:
Hi all, I'm trying to pass a fopen() ressource result as a parameter. $x=fopen($filename); header('location:myfile.php?ressource='.$x); but it doesn't seem to work. How to do so ?
20
7241
by: David Mathog | last post by:
A program of mine writes to a tape unit. Output can be either through stdout or through a file opened with fopen(). When all the data is transferred to tape the program needs to close the output...
15
2361
by: joker197cinque | last post by:
I'm trying to fopen a file this way: $handle = fopen("http://localhost/test.html", "r"); but tha page remains "loading .." for 30 seconds and then goes in timeout. However I can open that...
4
2819
by: Michel Rouzic | last post by:
I made a program that accepts as parameters an input file name that we'll call file1, and an output file name that we'll call file2, and opens on its own a configuration file called file3. My...
0
7090
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
6960
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7275
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...
1
4857
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4551
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...
0
3058
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1376
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 ...
1
595
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
247
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...

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.