I have a page that I am currently writing that is hosted on a singleboard computer. The current webpage that I am coding is used to setup the timezone and current time settings of the board. It features jquery items, javascript functions, a form with 3 submit buttons, php scripts, and a few linux command line exec calls being run, to change the timezone of the board from the commandline. I am also doing more than a handful of string comparisons when determining what the default dropdown item selection should be.
The issue I am having is very repeatable. If I submit the time zone, then change the time, set the time zone again, change the time again, and maybe repeat this one more time, the page doesn't completely load. Upon viewing the source, it is clear that the entire page is not being loaded completely. Usually it ends of failing somewhere within the dropdown selection creation.
For example, this is at the very bottom of the loaded source code file when it fails:
<input class="button" type="submit" name="getLocalTime" value="Copy Local Time"><br><br><br><table><tr><td colspan="2"><tr><td>
<select name="DropDownTimezone" id="DropDownTimezone">
<option value="Etc/GMT+12">(GMT -12:00) Eniwetok, Kwajalein</option>
<option value="Etc/GMT+11">(GMT -11:00) Midway Island, Samoa</option>
<option value="Etc/GMT+10">(GMT -10:00) Hawaii</option>
<option value="Etc/GMT+9">(GMT -9:00) Alaska</option>
<option value="Etc/GMT+8">(GMT -8:00) Pacific Time (US & Canada)</option>
<option value="Etc/GMT+7">(GMT -7:00)
That section is coded like this:
<select name="DropDownTimezone" id="DropDownTimezone">
<option <?php if ($hwOffset == "-12") echo 'selected'; ?> value="Etc/GMT+12">(GMT -12:00) Eniwetok, Kwajalein</option>
<option <?php if ($hwOffset == "-11") echo 'selected'; ?> value="Etc/GMT+11">(GMT -11:00) Midway Island, Samoa</option>
<option <?php if ($hwOffset == "-10") echo 'selected'; ?> value="Etc/GMT+10">(GMT -10:00) Hawaii</option>
<option <?php if ($hwOffset == "-9") echo 'selected'; ?> value="Etc/GMT+9">(GMT -9:00) Alaska</option>
<option <?php if ($hwOffset == "-8") echo 'selected'; ?> value="Etc/GMT+8">(GMT -8:00) Pacific Time (US & Canada)</option>
<option <?php if ($hwOffset == "-7") echo 'selected'; ?> value="Etc/GMT+7">(GMT -7:00) Mountain Time (US & Canada)</option>
<option <?php if ($hwOffset == "-6") echo 'selected'; ?> value="Etc/GMT+6">(GMT -6:00) Central Time (US & Canada), Mexico City</option>
<option <?php if ($hwOffset == "-5") echo 'selected'; ?> value="Etc/GMT+5">(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima</option>
<option <?php if ($hwOffset == "-4") echo 'selected'; ?> value="Etc/GMT+4">(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>
<option <?php if ($hwOffset == "-3") echo 'selected'; ?> value="Etc/GMT+3">(GMT -3:00) Brazil, Buenos Aires, Georgetown</option>
<option <?php if ($hwOffset == "-2") echo 'selected'; ?> value="Etc/GMT+2">(GMT -2:00) Mid-Atlantic</option>
<option <?php if ($hwOffset == "-1") echo 'selected'; ?> value="Etc/GMT+1">(GMT -1:00) Azores, Cape Verde Islands</option>
<option <?php if ($hwOffset == "+0") echo 'selected'; ?> value="Etc/GMT+0">(GMT) Western Europe Time, London, Lisbon, Casablanca</option>
<option <?php if ($hwOffset == "+1") echo 'selected'; ?> value="Etc/GMT-1">(GMT +1:00) Brussels, Copenhagen, Madrid, Paris</option>
<option <?php if ($hwOffset == "+2") echo 'selected'; ?> value="Etc/GMT-2">(GMT +2:00) Kaliningrad, South Africa</option>
<option <?php if ($hwOffset == "+3") echo 'selected'; ?> value="Etc/GMT-3">(GMT +3:00) Baghdad, Riyadh, Moscow, St Petersburg</option>
<option <?php if ($hwOffset == "+4") echo 'selected'; ?> value="Etc/GMT-4">(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>
<option <?php if ($hwOffset == "+5") echo 'selected'; ?> value="Etc/GMT-5">(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>
<option <?php if ($hwOffset == "+6") echo 'selected'; ?> value="Etc/GMT-6">(GMT +6:00) Almaty, Dhaka, Colombo</option>
<option <?php if ($hwOffset == "+7") echo 'selected'; ?> value="Etc/GMT-7">(GMT +7:00) Bangkok, Hanoi, Jakarta</option>
<option <?php if ($hwOffset == "+8") echo 'selected'; ?> value="Etc/GMT-8">(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option>
<option <?php if ($hwOffset == "+9") echo 'selected'; ?> value="Etc/GMT-9">(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>
<option <?php if ($hwOffset == "+10") echo 'selected'; ?> value="Etc/GMT-10">(GMT +10:00) Eastern Australia, Guam, Vladivostok</option>
<option <?php if ($hwOffset == "+11") echo 'selected'; ?> value="Etc/GMT-11">(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>
<option <?php if ($hwOffset == "+12") echo 'selected'; ?> value="Etc/GMT-12">(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
</select>
I am thinking that this has something to do with memory running out or a buffer filling up, since it does not fail every time, but will fail after roughly the same number of repeated steps. Are there any useful commands in PHP or methods to avoid having this issue? Or are there any other possible root causes for problems like this? Thanks in advance.