physaux Posted October 16, 2009 Share Posted October 16, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/177915-solved-warning-array_push-expects-parameter-1-to-be-array-null-givenbut-notnull/ Share on other sites More sharing options...
salathe Posted October 16, 2009 Share Posted October 16, 2009 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". Quote Link to comment https://forums.phpfreaks.com/topic/177915-solved-warning-array_push-expects-parameter-1-to-be-array-null-givenbut-notnull/#findComment-938054 Share on other sites More sharing options...
physaux Posted October 16, 2009 Author Share Posted October 16, 2009 tytytyty lol, i was stumped on that for over an hour.. thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/177915-solved-warning-array_push-expects-parameter-1-to-be-array-null-givenbut-notnull/#findComment-938057 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.