Вопрос

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?

Это было полезно?

Решение 2

You need to declace $admin to an array first

like

$admin=array();

then try

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

);

Другие советы

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"

);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top