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:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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