I have this simple script at my server http://preferans.de/mailru/test.php:
<?php
$page = file_get_contents('http://127.0.0.1/crossdomain.xml');
require_once 'HTTP/Request.php';
$r = new HTTP_Request('http://127.0.0.1/crossdomain.xml');
$r->sendRequest();
$page2 = $r->getResponseBody();
echo "<pre>\n";
print_r($_GET);
print $page;
print $page2;
echo "</pre>\n";
?>
It runs ok when run from the command line as "php index.php"
(prints the contents of http://preferans.de/crossdomain.xml twice),
but prints nothing (i.e. print only "Array ( )" for $_GET) when
called from a browser.
I'm using the stock Apache 1.3.x at OpenBSD 4.5 with the
following stock (i.e. delivered with OS) PHP packages:
php5-core-5.2.8p0 server-side HTML-embedded scripting language
php5-gd-5.2.8-no_x11 image manipulation extensions for php5
php5-pgsql-5.2.8 pgsql database access extensions for php5
It works since few years quite ok, running phpBB 3.0.x + Postgres
(upgraded few times), but now I need a new script which
would be able to fetch an external page and I can't get it working.
I'm not very proficient in PHP, please tell me,
how could I get more debugging information for my problem.
In the /var/www/conf/php.ini I have:
allow_url_fopen = On
and
display_errors = "stdout"
I also have a large "suhosin" section (as OpenBSD provides it),
haven't modified it. Also I have /var/www/etc/hosts containing
127.0.0.1 localhost
since Apache runs chrooted in /var/www under OpenBSD.
But (!!) I am also trying to run it non-chrooted (with "httpd -u")
and the script still does not work
Thank you for any help
Alex
Since this works from the command line but not from the browser, the
obvious question is - what's different?
You're obviously running under a different environment, with different
users, paths, etc. However, you could be using a different php
configuration or even a different version of PHP, for instance.
The first thing you should do is use phpinfo() to check your settings.
Do you have the expected settings in your web script? How do they
differ from the the working command line version? Especially check
which php.ini you are using - it might not be the one you expect.
Also, in addition to your display_errors directive, you should have
error_reporting=E_ALL | E_STRICT
in your php.ini file.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================
On 7 May, 14:05, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Since this works from the command line but not from the browser, the
> obvious question is - what's different?
>
> You're obviously running under a different environment, with different
> users, paths, etc. However, you could be using a different php
> configuration or even a different version of PHP, for instance.
>
> The first thing you should do is use phpinfo() to check your settings.
> Do you have the expected settings in your web script? How do they
> differ from the the working command line version? Especially check
> which php.ini you are using - it might not be the one you expect.
>
> Also, in addition to your display_errors directive, you should have
>
> error_reporting=E_ALL | E_STRICT
>
> in your php.ini file.
thank you and I've just happened to find
the 2 reasons (after half a day searching):
1) I had a setting prohibiting outgoing web requests in my firewall:
block out quick log on $ext_if proto { tcp, udp } all user www
2) Stupid one - I haven't see the fetched page content,
because it was in XML format and the browser wasn't
displaying stuff because of < and > brackets
Thanks again.
Alex