Jump to content

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.

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.