Edit report at http://bugs.php.net/bug.php?id=26368&edit=1

 ID:                 26368
 Comment by:         cindy dot dolan at yahoo dot com
 Reported by:        webmaster at x7chat dot com
 Summary:            Returns a Fatal error when using assign-ops
 Status:             Bogus
 Type:               Bug
 Package:            Arrays related
 Operating System:   Linux, Windows
 PHP Version:        4.3.3
 Block user comment: N
 Private report:     N

 New Comment:

I have the same issue at PHP 5.3.5, and the same fix. 



Looping through the output of a database query, I collect data on two
things - CPU & Memory - into two arrays.  Each is initialized
identically. 

  Data is collected like:  $cpu[$cntr] .= "<some more xml data>";  The
memory data is collected identically:  $mem[$cntr] .= "<some more xml
data>";



When I comment out the memory-related array data collection, the code
runs fine.  

When I include it, I get this crazy error.

When I change the syntax to:

  $mem[$cntr] = $mem[$cntr] . "new data";

it runs fine.


Previous Comments:
------------------------------------------------------------------------
[2004-09-23 01:41:03] penfield888 at yahoo dot com

Actually, I have error_reporting set to E_ALL, no error suppression
operators, all variables carefully initialized.  I get the error on
occasion on one server, not on others.  In a very simple situation, I
get the same error on code like this



$var['idx'] = '';

$var['idx'] .= "more string";



Others who have had the error seem to have had goodluck fixing it simply
by changing to



$var['idx'] = $var['idx'] . "more string";



which should change nothing.

------------------------------------------------------------------------
[2003-11-23 21:21:34] sni...@php.net

You have some problem in your script. Get rid of '@' and set
error_reporting(E_ALL); and you'll most likely find out what is wrong.
There is no bug here, this is expected behaviour.



------------------------------------------------------------------------
[2003-11-23 15:03:14] webmaster at x7chat dot com

Description:
------------
A certain script I wrote uses the following line of code:



$USER['TEMP'] .= "!";



When I run this some servers (Programmed on Redhat Linux 9 with PHP
4.3.3 and it works fine, tested on another Linux server using PHP 4.3.3
and it returns the error) it returns the following error message:



Fatal error: Cannot use assign-op operators with overloaded objects nor

string offsets in

(FILE PATH) on line (LINE NUMBER)



I have asked many different programmers about it and nobody has an
answer as to why it causes an error on code that is correct.  According
to PHP documentation the syntax of it is correct.  



Another person who has had this problem has documented it here:
http://www.faqchest.com/prgm/php-l/php-02/php-0205/php-020581/php02052416_25320.html.
 I distribute the script for free and I have had at least 4 different
users report that they are having this problem.



The variable $USER['TEMP'] has been defined before and is not null.

Reproduce code:
---------------
$q = DoQuery("SELECT * FROM $SERVER[TBL_PREFIX]users WHERE
username='$USER[NAME]'");

$USER['TEMP'] = $row[13];

$k = 1; $i = 0; $s = 0; $r[0] = "";

$USER['TEMP'] .= "!";

while($k){

$sub = substr($USER['TEMP'],$i,1);

if($sub == "!"){

$k = 0;

break;

}

if($sub == ","){

$s++;

}else{

@$r[$s] .= $sub;

}

$i++;

}

Expected result:
----------------
I would expect it to add "!" to $USER['TEMP'] every time it goes through
the while loop, on some servers it does but on others it returns the
error even if they are the same type of server running the same version
of PHP.

Actual result:
--------------
On some servers it works correctly and on others it says:



Fatal error: Cannot use assign-op operators with overloaded objects nor

string offsets in

(FILE PATH) on line (LINE NUMBER)


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=26368&edit=1

Reply via email to