PHP 4.0 Bug #2163: Problemes with associative arrays
| From: | xrr at altern dot org | Date: | Thu, 26 Aug 1999 11:39:11 +0000 |
| Subject: | PHP 4.0 Bug #2163: Problemes with associative arrays | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-10219@lists.php.net to get a copy of this message | ||
From: xrr@altern.org
Operating system: RedHat linux 2.2.5
PHP version: 4.0 Beta 2
PHP Bug Type: Reproduceable crash
Bug description: Problemes with associative arrays
I've got a peculiar problem with associative arrays.
Actually I haven't been able to precisly isolate the problem.
Probleme is appearing when I do something like
$coef[$q]=$c when $q and $c are string representing integers
If I change $q and $c to be integers then the problem disapears.
(replacing $q=$limiteArray("QuantiteMax") by $q=(int)$limitearray...)
Please do not hesitate to contact me for more information.
here's the script following by it's output :
<?
require 'sqlinfo.inc';
function test($coefs)
{
while (list ($a,$b)=each($coefs))
{
$coef[0]=$a;
$coef[1]=$b;
error_log("i=$i coefs[$a]=$b");
print "i=$i coefs[$a]=$b<BR>";
}
}
$id=1;
if (!$sqllink=sybase_pconnect($sqlhost, $sqluser, $sqlpasswd))
{
echo "Echec ouverture";
redirect_erreur();
}
if (!sybase_select_db("lideal", $sqllink))
{
echo "Echec selection db";
redirect_erreur();
}
if (!$result3=sybase_query(sprintf("select * from TLimite where
Deal_id=%d",$id),$sqllink))
{
error_log ("Echec requete");
}
$loop=0;
while ($LimiteArray=sybase_fetch_array($result3))
{
print "loop $loop<BR>";
error_log("loop $loop");
$loop=$loop+1;
$q=$LimiteArray["QuantiteMax"];
$c=$LimiteArray["coef"];
print "q=$q c=$c";
print "type(q)=".gettype($q)."<BR>";
print "type(c)=".gettype($c)."<BR>";
$coefs[$q]=$c;
print "tabledeal: coef[$q]=$c<BR>";
}
test($coefs);
?>
Script output
loop 0
q=100 c=5type(q)=string
type(c)=string
tabledeal: coef[100]=5
loop 1
q=200 c=10type(q)=string
type(c)=string
tabledeal: coef[200]=10
loop 2
q=1000 c=20type(q)=string
type(c)=string
tabledeal: coef[1000]=20
i= coefs[100]=5
i= coefs[200]=Array
i= coefs[1000]=20