Tagged: #TimeMemoryFunctionLocation, #TimeMemoryFunctionLocation error, foreach, retrieving options, retrieving settings
- This topic has 0 replies, 1 voice, and was last updated 5 years, 6 months ago by
semwangajoshua.
-
AuthorPosts
-
-
July 22, 2016 at 7:16 am #6995
semwangajoshuaMemberI have the code below for retrieving field values from a settings page.
<?php $theme_options = get_option('lawyeah_theme_settings'); $position4_vsb = $theme_options["stmp_postn4_vsb"]; foreach ($position4_vsb as $value) { echo "$value";}?>The challenge I’m facing is that if I make a fresh installation of my theme, I get an error like Call Stack #TimeMemoryFunctionLocation. This has not been happening on my old WordPress installation.Reason: Because it already has the array values in the database. But it does on any other WordPress installation because the database actually does not have the array values queried by foreach. I’ve done a little research and according to what I’ve found, the error comes as a result of querying the database for array values that don’t exist. The solution to the problem then, in my opinion is to provide a fallback/default value should the database not have those values. That way, foreach returns a default value or nothing at all should it not find the queried field values. I’ve been trying to pull this off but in vain. Could somebody help me figure out a way to make foreach silent in case it doesn’t find a value in the database instead of throwing fatal errors.
Attachments:
You must be logged in to view attached files.
-
-
AuthorPosts
- You must be logged in to reply to this topic.