Jump to content

Variable not maintaining values?


Dimensional

Recommended Posts

What server/php setting difference would cause a variable to be overwritten in a loop?

 

Local server = fine.

Live server = variable not maintaining values added in previous loops.

 

foreach($arr as $b){

  while($x<$y){

      $var[] = "value";

  }

}

On the live server $var will only contain the values of the final loop. On the local it will have values from every loop. I'm guessing something might be limiting its scope, but what?

Link to comment
https://forums.phpfreaks.com/topic/193494-variable-not-maintaining-values/
Share on other sites

Since that is not actual working code, nor does it contain a sample of the data and what results you are actually getting, it is impossible to tell you what could be causing the symptom.

 

Some guesses -

 

1) register_globals are on,

2) you only have one value, so all you get is that one/last value in the results.

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.