0

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..

Edited by happygeek: fixed formatting

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by nav33n
0

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

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

:)

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

0

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:)

0

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 ! :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.