php-general Digest 6 May 2006 22:39:24 -0000 Issue 4113
Topics (messages 235673 through 235686):
Re: hosting reselling
235673 by: Marc G. Fournier
Re: adding objects to spl.php because it doesn't appear to be there
235674 by: chris smith
Re: set_error_handler() fails
235675 by: Richard Lynch
235676 by: Richard Lynch
Re: causing HTTP error status
235677 by: Richard Lynch
235678 by: Richard Lynch
235681 by: Rabin Vincent
235682 by: Nic
235683 by: Ólafur Waage
235684 by: Nic
Re: List of sessions
235679 by: Richard Lynch
235685 by: tedd
235686 by: chris smith
Re: PHP Forms
235680 by: Richard Lynch
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
$6.99/mo, unlimited domains, virtual private server with full root access,
php5 and mysql 4.0 / 4.1 or 5.0 currently available ...
http://www.hub.org
On Sat, 6 May 2006, John Taylor-Johnston wrote:
Kind of off-topic.
My current ISP has problems with quality control: especially offering php 5 &
mysql.
Also rates keep going up per account. Reselling is beginning to look very
interesting.
Anyone have any recommendations for a reseller where I can host 5 sites
myself
with very low bandwidth and minimum harddrive space.
John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ: 7615664
--- End Message ---
--- Begin Message ---
On 5/6/06, jonathan <[EMAIL PROTECTED]> wrote:
a sample phpunit. the issue is that this class doesn't seem to be in
my spl (which I don't really use and am not sure how to upgrade).
If it's a sample, where does it come from? Best ask those folk, they
will know how to help you.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On Fri, May 5, 2006 6:20 am, icy wrote:
> chris smith wrote:
>>
>> What does your code look like?
>
> I just realized that when called a second time, set_error_handler()
> returns my custom error handler but it is never triggered.
> Code looks like this:
>
> <?php
> if (set_error_handler('core_error_handler', E_ALL) === NULL)
I'm not sure E_ALL is kosher there, since E_ALL include E_ERROR, and
E_ERROR can't be caught by an error handler...
Try doing it without the E_ALL, since it's going to catch everything
it can by default anyway.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Fri, May 5, 2006 8:08 am, Martin Alterisio \"El Hombre Gris\" wrote:
> And set_error_handler() returns NULL because there isn't a previously
> defined error handler, not because it failed.
Since it's documented to return NULL when it fails to set the error
handler, one would hope it does NOT return NULL if there was no
previously-defined error handler... That would be bad.
You'd never be able to distinguish between the error condition NULL
and the no previous handler NULL. :-(
It probably returns FALSE, 0, or '' in that case, though the docs are
imprecise on that very point... That may also have changed in
different versions of PHP as set_error_handler pre-dates TRUE/FALSE
values for a true BOOL datatype...
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Fri, May 5, 2006 3:41 am, Nic wrote:
> "Richard Lynch" <[EMAIL PROTECTED]> writes:
>
>> On Thu, May 4, 2006 8:50 am, Nic wrote:
>>> I'm having trouble with setting HTTP error status from PHP4.
>>>
>>> The PHP docs say that if I have this :
>>>
>>> <Directory /mydir>
>>
>> WILD GUESS!!!
>>
>> Try it with full pathname to /mydir, or perhaps without the leading
>> '/' or some combination of more/fewer directories and/or slashes.
>
> No. /mydir is the directory I want the error page served for.
>
> It does actually work outside the PHP environment, eg:
>
> <Directory /mydir>
> ErrorDocument 404 "hello!!!"
> </Directory>
>
> and requesting /mydir/not_there returns a 404 with "hello!!!" in the
> page.
>
> But /mydir/some.php doing:
>
> header("HTTP/1.1 404 Rubbish!!!")
>
> _never_ causes the error document to be picked up.
>
> It's strange because the docs say this can be done; I can't find an
> example that is purported to work outside of the docs though.
Hmmmmm.
I wonder if it only works in CGI or web SAPI but not the other.
Though I can't even guess which way that would go...
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Fri, May 5, 2006 5:01 am, Nic wrote:
> Hi Rabin
> "Rabin Vincent" <[EMAIL PROTECTED]> writes:
>
>> On 5/5/06, Nic <[EMAIL PROTECTED]> wrote:
>>> But /mydir/some.php doing:
>>>
>>> header("HTTP/1.1 404 Rubbish!!!")
>>>
>>> _never_ causes the error document to be picked up.
>>
>> That's right. Apache's not going to take action based
>
> mod_perl and mod_python can both do this. As can CGIs. So I'll be
> really surprised if this isn't possible with PHP.
>
>>> It's strange because the docs say this can be done; I can't find an
>>> example that is purported to work outside of the docs though.
>>
>> Where do the docs say this? I can't find it in
>> http://php.net/header.
>
> The url is:
>
> http://www.php.net/manual/en/function.header.php
>
> The relevant bit is where it says:
>
> There are two special-case header calls. The first is a header that
> starts with the string "HTTP/" (case is not significant), which
> will be used to figure out the HTTP status code to send. For
> example, if you have configured Apache to use a PHP script to
> handle requests for missing files (using the ErrorDocument
> directive), you may want to make sure that your script generates
> the proper status code.
>
> <?php
> header("HTTP/1.0 404 Not Found");
> ?>
I gotta go with Nic on this...
Either I'm being really obtuse, or it just plain don't work right.
Consider this minimalist example:
http://l-i-e.com/404/test.php
http://l-i-e.com/404/index.htm
The 404 header is being completely ignored, afaict
I tried adding "exit;" right after the header, and my browser just
goes way long time and then times out.
I tried HTTP/1.1 and that made no difference.
I'd suggest checking http://bugs.php.net and filing a bug report if
it's not a known issue...
Unless somebody can point out something wrong in our logic.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On 5/6/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
On Fri, May 5, 2006 5:01 am, Nic wrote:
> Hi Rabin
> "Rabin Vincent" <[EMAIL PROTECTED]> writes:
>
>> On 5/5/06, Nic <[EMAIL PROTECTED]> wrote:
>>> But /mydir/some.php doing:
>>>
>>> header("HTTP/1.1 404 Rubbish!!!")
>>>
>>> _never_ causes the error document to be picked up.
>>
>> That's right. Apache's not going to take action based
>
> mod_perl and mod_python can both do this. As can CGIs. So I'll be
> really surprised if this isn't possible with PHP.
>
>>> It's strange because the docs say this can be done; I can't find an
>>> example that is purported to work outside of the docs though.
>>
>> Where do the docs say this? I can't find it in
>> http://php.net/header.
>
> The url is:
>
> http://www.php.net/manual/en/function.header.php
>
> The relevant bit is where it says:
>
> There are two special-case header calls. The first is a header that
> starts with the string "HTTP/" (case is not significant), which
> will be used to figure out the HTTP status code to send. For
> example, if you have configured Apache to use a PHP script to
> handle requests for missing files (using the ErrorDocument
> directive), you may want to make sure that your script generates
> the proper status code.
>
> <?php
> header("HTTP/1.0 404 Not Found");
> ?>
I gotta go with Nic on this...
Either I'm being really obtuse, or it just plain don't work right.
Consider this minimalist example:
http://l-i-e.com/404/test.php
http://l-i-e.com/404/index.htm
The 404 header is being completely ignored, afaict
I tried adding "exit;" right after the header, and my browser just
goes way long time and then times out.
I tried HTTP/1.1 and that made no difference.
I'd suggest checking http://bugs.php.net and filing a bug report if
it's not a known issue...
Unless somebody can point out something wrong in our logic.
The doc paragraph refers to a PHP error handler script. In
the case of a normal script like your test case:
I've just been reading to see why this header throwing does
not cause Apache to kick in its ErrorDocument. Apache allows
handlers to handle different stages of the request, and it
takes action based on what the handler returns after looking
at the request.
In the case of mod_python, mod_python allows you to write
the handler, which would normally be written in C, in Python. Thus,
you can return the 404 code from the handler callback, and
Apache will show ErrorDocument.
In PHP, mod_php itself is the handler. It doesn't allow your script
access to the Apache API in the way that mod_python does. Looking
at the sapi code in PHP, it seems to returns OK to Apache
regradless of what goes on in the called script (i.e, it's not parsing
the headers emitted, if any). Thus, throwing a 404 header in
your script will not invoke Apache's ErrorDocument, since Apache
doesn't know anything is wrong.
I just got that from these two docs, so there may be some
Apache details I'm missing/overlooking:
http://www.modpython.org/python10/
http://httpd.apache.org/docs/1.3/misc/API.html
Rabin
--
http://rab.in
--- End Message ---
--- Begin Message ---
"Richard Lynch" <[EMAIL PROTECTED]> writes:
> On Fri, May 5, 2006 5:01 am, Nic wrote:
>> Hi Rabin
>> "Rabin Vincent" <[EMAIL PROTECTED]> writes:
>>
>>> On 5/5/06, Nic <[EMAIL PROTECTED]> wrote:
>>>> But /mydir/some.php doing:
>>>>
>>>> header("HTTP/1.1 404 Rubbish!!!")
>>>>
>>>> _never_ causes the error document to be picked up.
>>>
>>> That's right. Apache's not going to take action based
>>
>> mod_perl and mod_python can both do this. As can CGIs. So I'll be
>> really surprised if this isn't possible with PHP.
>>
>>>> It's strange because the docs say this can be done; I can't find an
>>>> example that is purported to work outside of the docs though.
>>>
>>> Where do the docs say this? I can't find it in
>>> http://php.net/header.
>>
>> The url is:
>>
>> http://www.php.net/manual/en/function.header.php
>>
>> The relevant bit is where it says:
>>
>> There are two special-case header calls. The first is a header that
>> starts with the string "HTTP/" (case is not significant), which
>> will be used to figure out the HTTP status code to send. For
>> example, if you have configured Apache to use a PHP script to
>> handle requests for missing files (using the ErrorDocument
>> directive), you may want to make sure that your script generates
>> the proper status code.
>>
>> <?php
>> header("HTTP/1.0 404 Not Found");
>> ?>
>
> I gotta go with Nic on this...
>
> Either I'm being really obtuse, or it just plain don't work right.
>
> Consider this minimalist example:
>
> http://l-i-e.com/404/test.php
> http://l-i-e.com/404/index.htm
>
> The 404 header is being completely ignored, afaict
>
> I tried adding "exit;" right after the header, and my browser just
> goes way long time and then times out.
>
> I tried HTTP/1.1 and that made no difference.
>
> I'd suggest checking http://bugs.php.net and filing a bug report if
> it's not a known issue...
>
> Unless somebody can point out something wrong in our logic.
I think this got cleared up.
Setting the response code (to 404 or 500) is available so that when a
PHP _is_ an error page it can set the code correctly; eg:
apache config:
<Directory /someplace>
ErrorDocument 404 /somplace/error.php
</Directory>
/someplace/error.php
<?php
header("HTTP/1.1 404 Not Found");
echo "<html><body><h1>Sorry, the page you wanted wasn't
found.</h1></body></html>";
?>
But I'm still schocked that PHP can't cause the Apache error page to
be served. It seems such a basic thing and all the other web
environments I know (even apache + servlets) allow this.
Ah well.
Nic
--- End Message ---
--- Begin Message ---
Nic wrote:
"Richard Lynch" <[EMAIL PROTECTED]> writes:
On Fri, May 5, 2006 5:01 am, Nic wrote:
Hi Rabin
"Rabin Vincent" <[EMAIL PROTECTED]> writes:
On 5/5/06, Nic <[EMAIL PROTECTED]> wrote:
But /mydir/some.php doing:
header("HTTP/1.1 404 Rubbish!!!")
_never_ causes the error document to be picked up.
That's right. Apache's not going to take action based
mod_perl and mod_python can both do this. As can CGIs. So I'll be
really surprised if this isn't possible with PHP.
It's strange because the docs say this can be done; I can't find an
example that is purported to work outside of the docs though.
Where do the docs say this? I can't find it in
http://php.net/header.
The url is:
http://www.php.net/manual/en/function.header.php
The relevant bit is where it says:
There are two special-case header calls. The first is a header that
starts with the string "HTTP/" (case is not significant), which
will be used to figure out the HTTP status code to send. For
example, if you have configured Apache to use a PHP script to
handle requests for missing files (using the ErrorDocument
directive), you may want to make sure that your script generates
the proper status code.
<?php
header("HTTP/1.0 404 Not Found");
?>
I gotta go with Nic on this...
Either I'm being really obtuse, or it just plain don't work right.
Consider this minimalist example:
http://l-i-e.com/404/test.php
http://l-i-e.com/404/index.htm
The 404 header is being completely ignored, afaict
I tried adding "exit;" right after the header, and my browser just
goes way long time and then times out.
I tried HTTP/1.1 and that made no difference.
I'd suggest checking http://bugs.php.net and filing a bug report if
it's not a known issue...
Unless somebody can point out something wrong in our logic.
I think this got cleared up.
Setting the response code (to 404 or 500) is available so that when a
PHP _is_ an error page it can set the code correctly; eg:
apache config:
<Directory /someplace>
ErrorDocument 404 /somplace/error.php
</Directory>
/someplace/error.php
<?php
header("HTTP/1.1 404 Not Found");
echo "<html><body><h1>Sorry, the page you wanted wasn't
found.</h1></body></html>";
?>
But I'm still schocked that PHP can't cause the Apache error page to
be served. It seems such a basic thing and all the other web
environments I know (even apache + servlets) allow this.
Ah well.
Nic
Wild Guess here but isnt it because apache defines within its config the
error pages before it defines .php as a usable proccess?
--- End Message ---
--- Begin Message ---
"Rabin Vincent" <[EMAIL PROTECTED]> writes:
> In PHP, mod_php itself is the handler. It doesn't allow your script
> access to the Apache API in the way that mod_python does. Looking
> at the sapi code in PHP, it seems to returns OK to Apache
> regradless of what goes on in the called script (i.e, it's not parsing
> the headers emitted, if any). Thus, throwing a 404 header in
> your script will not invoke Apache's ErrorDocument, since Apache
> doesn't know anything is wrong.
You're absolutely right - that is what is happening.
In fact in mod_python one has to raise an exception with the return
value to get the error page to be served. I can't remember how it
works in mod_perl.
I had an expectation that PHP would be parsing the returned header and
internally redirecting to the errordocument if necessary.
I guess that doesn't make any sense because the page the error is
generated from might have content that shouldn't be discarded.
It might make sense to do this on exit(x) if x>0 but I'm not sure.
Nic
--- End Message ---
--- Begin Message ---
On Thu, May 4, 2006 10:56 pm, Tony Aldrich wrote:
>>
>> Honestly, the easiest way to solve this is to switch to 'user' PHP
>> sessions:
>> http://php.net/session-set-save-handler
>
>
> Thanks. I'm trying now to do this.
> I'm wondering about "session-set-save-handler" - what is "manual
> garbage
> collector" here?
> It means I must explicitly "unset" all variables or something else I
> must
> do?
You'd want to delete any records from your database that are "stale"
This is the important part of what you were asking about in the first
place.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Hi:
While we're on the subject of listing sessions, what does the
following code do?
session_start();
$path = ini_get('session.save_path');
$handle = dir($path);
while ($filename = $handle->read())
{
if (substr($filename, 0, 5) == 'sess_')
{
$data = file_get_contents("$path/$filename");
if (!empty($data))
{
session_decode($data);
$session = $_SESSION;
$_SESSION = array();
echo("<pre>");
echo "Session [" .
substr($filename, 5) . "]\n";
print_r($session);
echo "\n--\n\n";
echo("</pre>");
}
}
}
It looks dangerous.
tedd
--
--------------------------------------------------------------------------------
http://sperling.com
--- End Message ---
--- Begin Message ---
On 5/7/06, tedd <[EMAIL PROTECTED]> wrote:
Hi:
While we're on the subject of listing sessions, what does the
following code do?
session_start();
$path = ini_get('session.save_path');
$handle = dir($path);
while ($filename = $handle->read())
{
if (substr($filename, 0, 5) == 'sess_')
{
$data = file_get_contents("$path/$filename");
if (!empty($data))
{
session_decode($data);
$session = $_SESSION;
$_SESSION = array();
echo("<pre>");
echo "Session [" .
substr($filename, 5) . "]\n";
print_r($session);
echo "\n--\n\n";
echo("</pre>");
}
}
}
Goes through 'session.save_path' and looks for session files. If it
finds one, it opens it and prints it out.
Could be quit dangerous on a shared host, yes.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On Thu, May 4, 2006 9:57 pm, R. Van Tassel wrote:
> I am having an issue with a form, basically an order form, with 10
> rows.
> Each row is the same, the rows are being generated by a loop and I am
> appending the counter of the loop to the name of the form elements
> (i.e.
> quantity1, type1, next row = quantity2, type2, etc)
Save yourself a lot of headaches and use:
NAME="quantity[1]"
It will be an array when you process it with $_POST
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---