Question

I'm getting this error:

'( ! ) Warning: Cannot use a scalar value as an array in C:\xampp\htdocs\or2LAST\admin\adminData.php on line 5`

the code for this error (line 5):

$admin['push']=array(
        1=>"yes",
        2=>"no"

);

i tried to use "1" & "2" for the key but it didn't solve the problem.

where is the problem and why this error occurred?

Was it helpful?

Solution 2

You need to declace $admin to an array first

like

$admin=array();

then try

$admin['push']=array(
    1=>"yes",
    2=>"no"

);

OTHER TIPS

The problem is with $admin. You need to declare it as an array before using it:

$admin = array();

Whatever it is now, it's not an array. Possibly on a previous line you're overwriting it with some new (scalar) value instead of appending to it.

Your problem is probably with variable $admin, following should work just fine (assuming $admin is not previously declared).

$admin = array(); //<--!!
$admin['push']=array(
    1=>"yes",
    2=>"no"

);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top