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