Bug #46561 [Nab->Csd]: Warning:Cannot add element to the array as the next element is already occupied

From: Date: Fri, 07 Feb 2020 06:10:19 +0000
Subject: Bug #46561 [Nab->Csd]: Warning:Cannot add element to the array as the next element is already occupied
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225410@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=46561&edit=1 ID: 46561 Updated by: phpdocbot@php.net Reported by: jian at theorchard dot com Summary: Warning:Cannot add element to the array as the next element is already occupied -Status: Not a bug +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: * PHP Version: 5.2.6 Block user comment: N Private report: N New Comment: Automatic comment on behalf of rquadling Revision: http://git.php.net/?p=doc/en.git;a=commit;h=69ae2850dfab59f1f2fc5520f620238b22fc75b7 Log: css =&gt; cssversion. Fix #46561 Previous Comments: ------------------------------------------------------------------------ [2008-12-09 12:52:22] jani@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php ------------------------------------------------------------------------ [2008-11-16 01:15:33] jian at theorchard dot com I'm not sure if this code really adds an element with key 0x80000000 and then an other with 0x7FFFFFFF? It's very hard to reproduce it. It only has happened twice. Your suggestion should fix the problem. But I was so surprised that I got that warning. ------------------------------------------------------------------------ [2008-11-15 15:26:29] lbarnaud@php.net Does this code really adds an element with key 0x80000000 and then an other with 0x7FFFFFFF ? There is many possible work arounds for this issue. The simplest one is probably to do $this->drives[$row['drive_id']] = $row['drive_id']. ------------------------------------------------------------------------ [2008-11-14 20:52:33] jian at theorchard dot com Ok. So the fix was to add the missing warning. Then the warnings I got from my code doesn't apply to this fix. Ok, here's what happened in my case. I have a small class that is like this below. <? class myClass{ public $drives = array(); public function get_drives(){ $sql = 'CALL some_stored_procedure()'; $result = mysql_query($sql); if(mysql_num_rows($result)){ while($row = mysql_fetch_array($result)){ $this->drives[] = $row['drive_id']; } } } } ?> Line "$this->drives[] = $row['drive_id'];" throws out the same warning. I'm scracthing my head trying to resolve this. Any ideas? ------------------------------------------------------------------------ [2008-11-14 18:24:52] lbarnaud@php.net What was fixed in #41685 is that array_push() was not producing warnings in this case (the fix has added the warning in array_push()). ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=46561 -- Edit this bug report at https://bugs.php.net/bug.php?id=46561&edit=1

« previous php.bugs (#225410) next »