Re: [PHP4BETA] lates libzend update did bad things - GOT IT!

From: Date: Fri, 03 Sep 1999 14:11:17 +0000
Subject: Re: [PHP4BETA] lates libzend update did bad things - GOT IT!
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-4036@lists.php.net to get a copy of this message
Ok, that makes sense. I'll think about it some more, but I think I'll reverse my yesterday's patch in favour of giving everybody some more strict guidelines as to what it means to convert IS_LONG's to IS_RESOURCE's. Stay tuned :) Zeev At 15:12 03/09/99 , Thies C. Arntzen wrote:
zeev, the problem is boolean operators on resources! <? $conn=mysql_connect("127.0.0.1"); for ($inx = 0; $inx < 10; $inx++) {
    $r = mysql_db_query("test", "select * from phptest");
    if ($r == false) {} // comment this line out and it'll work!
    $array = mysql_fetch_array($r);
} echo "-----------------------end--------------\n";flush(); ?> just insert the "if ($r == false) {}" line and the resource will no longer work. regards, tc On Fri, 3 Sep 1999, Zeev Suraski wrote: At 14:20 03/09/99 , Thies C. Arntzen wrote:
On Fri, 3 Sep 1999, Zeev Suraski wrote:
At 10:45 03/09/99 , Thies C. Arntzen wrote:
zeev, the lates update broke something... <? $conn=mysql_connect("127.0.0.1"); for ($inx = 0; $inx < 10; $inx++) {
    $r = mysql_db_query("test", "select * from phptest");
    $array = mysql_fetch_array(&$r);
// mysql_free_result($r); } echo "-----------------------end--------------\n";flush(); ?> used to work - now says: PHP Warning: 2 is not a MySQL result index in mysql.php3 on line 6
Well, why are you sending the result handle by reference? My API patch doesn't make miracles, it keeps the existing C code in a way it
would work
nicely, but not with weirdo stuff like that :) To avoid these
errors, you
would have to actually modify the C code to be PHP 4.0 style (which
I will
today, but I'll only do the MySQL module).
sorry, that was a leftover.. it seems to work without the '&' - but have a look at #2230 - i have the same problem with some oracle-php-code i've written.
Basically, mysql_fetch_array() expects to receive a copy of the result handle, and it destroys it when it's done with it (transparently, mysql_fetch_array() was never designed to do it). Since you now
send it
the actual handle itself and not a copy - the handle that's
destroyed is
the only handle, and the object is dead by the time PHP wants to
use it.
hmm got you - i will have a deeper look why my code stopped working this morning - again, i'm not the only one (#2230) - so some thing has changed;-)
Basically, if you take any resource by reference, and you convert_to_long() it - the resource goes bye-bye. With PHP 4.0, you shouldn't call convert_to_long() on an expected resource, but instead, check whether the type is IS_RESOURCE, bail out if it isn't, and just use it as-is. Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il -- PHP 4 Beta
Thies C. Arntzen                 "One Big-Mac, Small Fries and a Coke!"
Digital Collections             Phone +49 40 235350 Fax +49 40 23535180
Hammerbrookstr. 93                              20097 Hamburg / Germany
-- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il

« previous php.version4 (#4036) next »