Welcome Guest, Not a member yet? Register   Sign In
View variable dying in foreach
#1

This is a weird one so please bare with me, I am new to Code Igniter, but I have spent a day fighting this and can't find a good answer.

So a variable is exposed to the view and I have a loop like the following that can use it correctly to fill the options in a select input:

<select id="region_id" name="region_id" onchange="setOptions();">
<option value="">Select Area</option>
<?php $selected = set_value('region_id', (empty($region_id) ? '' : $region_id)); ?>
<?php foreach ($regions as $region) :
if (!empty($region->published)) : ?>
<option value="<?=$region->region_id?>" <?=(set_value('region_id', $selected)==$region->region_id?' selected="selected"':'')?>><?=htmlentities($region->name)?>
</option>
<?php endif;
endforeach; ?>

Now elsewhere in the same view, if I go to use this $regions variable again (before or after this instance that is working), it causes the page to throw a connection time out. I have my PHP.ini timeouts set to over 10 seconds and it times out in only 3-4 seconds and watching memory allocation (which I also bumped up) there is no spike. I can echo out a count of the items in the $regions array, but even something as simple as this causes the error:

<?php foreach ($regions as $region) :

endforeach; ?>

I am completely baffled on what would cause this but figured that there must be an obvious explanation. Any thoughts?
Reply


Messages In This Thread
View variable dying in foreach - by bspizzle - 07-07-2015, 04:18 PM
RE: View variable dying in foreach - by mwhitney - 07-08-2015, 07:41 AM
RE: View variable dying in foreach - by gadelat - 07-08-2015, 07:43 AM
RE: View variable dying in foreach - by bspizzle - 07-08-2015, 08:25 AM
RE: View variable dying in foreach - by bspizzle - 07-08-2015, 08:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB