Jump to content

[SOLVED] Warning: array_push() expects parameter 1 to be array, null given//BUT NOTNULL??


physaux

Recommended Posts

Hey guys, i am having a really annoying problem...

Basically, my array is never set on the global scale... check out the code below

<?php
//functions defined here
//...
$OrderOfOperations= array();
//...
createorders();
?>

That is my declaration, and call to a function.

Here is the function which is called, "createorders()":

<?php
//...
global $OrderOfOperations;
//...
if(didhappen($chance)){
echo "it did happen, size of array now is ".count($OrderOfOperations)."<br>";
createnames($index, $index2, $index, $index3);
updateorderofoperations($index, $index2, $index, $index3);//Calls another method
?>

And here is finally the code for the function "updateorderofoperations()":

<?php
global $OrderArray;
global $OrderOfOperations;
$temptext="OrderArray: ".$OrderArray[$site1index1][$site1index2]["Name"]." sends to ". $OrderArray[$site2index1][$site2index2]["Name"];
array_push($OrderofOperations, $temptext);     //THIS IS LINE 172
echo "From inside function<br>";
?>

 

when i run the code, i just get the following output looped:

Warning: array_push() expects parameter 1 to be array, null given in /Users/../includes/functions.php on line 172
From inside function
it did happen, size of OOO is 0

 

So i can see that the method was called successfully, because of the "from inside function" text. I do not understand what is wrong to cause my error though, as well as why my master array does not accumulate values.

Am i not adding to an array properly?

Idk

 

So, anyone see any problems? Please help me out :confused:

Variable names are case-sensitive. In the line with array_push, you use the variable $OrderofOperations whereas elsewhere you use $OrderOfOperations - note the capitalisation of "Of".

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.