None of them need global, just that initial config that calls them up with includes, that's where the variable is killed. I print the in & out value for every page & that's where it ends.

I have no idea why.

What would destroy the variable? All the other pages get it from that page just fine but that page it comes up as undefined and global simply defines it as empty. I tried static so it doesn't go away. I'm re-setting $pics from the settings page where I put it in a $POST, refresh, get it from the $POST & assign it to $pics. I even tried grabbing it from $POST in the config file to jump the gap but it's killed in $POST too! I thought $POST was a superglobal. What would make that lose it's value?

Any ideas?


Paul Furman wrote:


The template wipes it out on the second round through after changing in settings. Coming into the template the second time it prints out empty. If I don't use global, the template gives an error that the variable doesn't exist.

OK, well what I'm calling the template is really the configuration file which does an include on the template that includes the screens. I set global in all of those.

Paul Furman wrote:

Help.
After changing $pics on the setting screen, the picture screen will not recognize the new value.


I'm just not clear where I need to set global (where it's being initially set or where it's being picked up later) especially where it bounces back & forth several times. For now I have global $pics everywhere. Is that bad?

Paul Furman wrote:


template: -------------------- global $pics; if (!isset($pics)){$pics = 8;}


picture screen: -------------------- global $pics; # works fine with the setting 8 from the template

settings screen:
--------------------
global $pics;
print $pics; #for debugging, always follows template setting
if (!isset($pics)){$pics = 5;}
  if ($_POST){
    if (isset ($_POST['thumbs'])){
      $pics = $_POST['thumbs'];
      print "settings have been changed";
    }
}

?>

<form name="mail" action="<?php SCREEN_DIR . "/settings.php" ?>" method="post">
<label for="thumbs">number of thumbnails per page: </label>
<input type="text" name="thumbs" id="thumbs" size="2"
value="<?php print $pics ?>">
<button type="submit">OK</button>
</form>

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to