Dear buddies,,

Fatal error: [] operator not supported for strings in c:\PHP5\www\\registration-reports-result.php on line 197

and the 197th line is

if($english_level!='0'){
$query_array[]= "reg_english_level.english_level1  = '". $english_level . "' OR reg_english_level.english_level2 = '". $english_level . "' OR reg_english_level.english_level3 = '". $english_level . "'";}

any help is appreciable..

Jino..

Try taking the single quotes away from the zero in this line:

if($english_level!='0') change to if($english_level!= 0)

:)

Try taking the single quotes away from the zero in this line:

if($english_level!='0') change to if($english_level!= 0)

:)

No. That ain't the reason for this error. !='0' works just the same like !=0, as in the following example.

<?php
$english_level=0;
if($english_level=='0'){
$query_array[]= "reg_english_level.english_level1 = '". $english_level . "' OR reg_english_level.english_level2 = '". $english_level . "' OR reg_english_level.english_level3 = '". $english_level . "'";
}
print_r($query_array);
?>

The problem is usually caused when you have already declared $query_array as a string by assigning some value and then use it as an array. For example,

<?php
$x="Test !";
$x[]="is this an array?";
print_r($x); //this will generate the same error as above!
?>

Cheers,
Naveen

Ah yes, so it is, sorroy my fault. I think though it is bad programming practice to pass an integer this way, but if it were ment to be parsed as a string, it's better to type cast the data type to clear up any confusion for other programmers:)

I think though it is bad programming practice to pass an integer this way, but if it were ment to be parsed as a string, it's better to type cast the data type to clear up any confusion for other programmers

Exactly ! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.