For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > July 2006 > fopen() problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author fopen() problem
pieterprovoost@gmail.com

2006-07-31, 7:09 pm

Hi,

Can anyone tell me why going to
http://www.algaebase.org/Distributi...y1A0A54
A

yields results, while the same page retrieved with fopen() says 'no
results'?

<?php
$pageurl='http://www.algaebase.org/DistributionResponse.lasso?currentMethod=distro&sk=20&- session=abv3:D5C1E5F111d2e05040XVy1A0A54
A';
$exthandle = fopen($pageurl, "r");
$content = file($pageurl);
fclose($exthandle);
echo(implode("",$content));
?>

Thanks
Piet

Erwin Moller

2006-07-31, 7:09 pm

pieterprovoost@gmail.com wrote:

> Hi,
>
> Can anyone tell me why going to
>

http://www.algaebase.org/Distributi...y1A0A54
A

> yields results, while the same page retrieved with fopen() says 'no
> results'?
>
> <?php
>

$pageurl='http://www.algaebase.org/DistributionResponse.lasso?currentMethod=distro&sk=20&- session=abv3:D5C1E5F111d2e05040XVy1A0A54
A';
> $exthandle = fopen($pageurl, "r");
> $content = file($pageurl);
> fclose($exthandle);
> echo(implode("",$content));
> ?>
>
> Thanks
> Piet


Hi,

Open the same URL with Wget or something similar.
That way you can see the response.
Maybe it is redirecting?

Regards,
Erwin Moller
Jerry Stuckle

2006-07-31, 7:09 pm

pieterprovoost@gmail.com wrote:
> Hi,
>
> Can anyone tell me why going to
> http://www.algaebase.org/Distributi...y1A0A54
A

> yields results, while the same page retrieved with fopen() says 'no
> results'?
>
> <?php
> $pageurl='http://www.algaebase.org/DistributionResponse.lasso?currentMethod=distro&sk=20&- session=abv3:D5C1E5F111d2e05040XVy1A0A54
A';
> $exthandle = fopen($pageurl, "r");
> $content = file($pageurl);
> fclose($exthandle);
> echo(implode("",$content));
> ?>
>
> Thanks
> Piet
>


The first one gives me no results, either.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Chung Leong

2006-07-31, 7:09 pm

pieterprovoost@gmail.com wrote:
> Hi,
>
> Can anyone tell me why going to
> http://www.algaebase.org/Distributi...y1A0A54
A

> yields results, while the same page retrieved with fopen() says 'no
> results'?
>
> <?php
> $pageurl='http://www.algaebase.org/DistributionResponse.lasso?currentMethod=distro&sk=20&- session=abv3:D5C1E5F111d2e05040XVy1A0A54
A';
> $exthandle = fopen($pageurl, "r");
> $content = file($pageurl);
> fclose($exthandle);
> echo(implode("",$content));
> ?>
>
> Thanks
> Piet


This works when the session is fresh:

<?php

$pageurl='http://www.algaebase.org/DistributionResponse.lasso?currentMethod=distro&sk=0&- session=abv3:8008664A11d922E7E0QsT317D41
5';
echo file_get_contents($pageurl);

?>

Why are you using fopen() and file() and the same time?

pieterprovoost@gmail.com

2006-07-31, 7:09 pm


Chung Leong wrote:
> pieterprovoost@gmail.com wrote:
>
> This works when the session is fresh:
>
> <?php
>
> $pageurl='http://www.algaebase.org/DistributionResponse.lasso?currentMethod=distro&sk=0&- session=abv3:8008664A11d922E7E0QsT317D41
5';
> echo file_get_contents($pageurl);
>
> ?>
>
> Why are you using fopen() and file() and the same time?


The code is a bit messy indeed, sorry for that. However, this worked
very fine before without ever changing the session name...

Miguel Cruz

2006-07-31, 7:09 pm

"pieterprovoost@gmail.com" <pieterprovoost@gmail.com> wrote:
> Can anyone tell me why going to
> http://www.algaebase.org/Distributi...od=distro&sk=20
> &- session=abv3:D5C1E5F111d2e05040XVy1A0A54
A
> yields results, while the same page retrieved with fopen() says 'no
> results'?


That URL doesn't contain your search terms.

It contains a reference ("abv3:D5C1E5F111d2e05040XVy1A0A54A") to a
session stored on the server's hard drive which in turn holds your
search terms.

That session has a finite lifespan, and after that (maybe half an hour
or so) the server throws it away, and the URL becomes invalid.

If you want this to work and you do not control the algaebase server,
you are going to have to use curl to build a form submission and collect
the results. You cannot, to my knowledge do this with fopen(). You could
do your own HTTP transaction with fsockopen() et al but that would be
overkill.

miguel
--
Photos from 40 countries on 5 continents: http://travel.u.nu
Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
Airports of the world: http://airport.u.nu
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com