Tags
PHP
Asked 5 years ago
15 Nov 2019
Views 826
Phpworker

Phpworker posted

Uncaught Error: [] operator not supported for strings in php


while($data=mysql_fetch_assoc($res)){
			
			$ldr[]=$data;
		}
		 


i am not finding any problem at all still it says
Uncaught Error: [] operator not supported for strings in php at line $ldr[]=$data;
yogi

yogi
answered Nov 30 '-1 00:00

Try to intialize the array instead of string to variable

$ldr=array();
while($data=mysql_fetch_assoc($res)){
			
			$ldr[]=$data;
		}

may be you declared $ldr as string so and it with empty string .string is also array of the character but with $ldr[0] first element they dont have anything at empty string .

so try to declare as array instead of string .
Post Answer