The error says that the item_id word in that code is being seen as a constant and not a variable. While the code snippet is useful, it doesn't tell us much without the backtrace to find out the location of the code that is causing the fatal error. I run Formidable every day in my development environment built with PHP/8.2.1 and Formidable has no problems. Even though I doubt it's a problem with Formidable and more likely some custom code snippet, are you on the latest version of Formidable? What code is causing the problem? You should be able to see a backtrace in you server's PHP error log.
WOW. Thanks a lot. I never thought of it. Sorry for this amateur question given I am not a programmer myself. I kind of copied and pasted it about 7 years ago from the web and it worked fine until PHP8. I am posting all of my code below. Maybe you can help to take a look at it. Many thanks in advance.
This is the code snippet (old). Where did I do wrong? I am totally blind. xD I believe this is the code that causes the issue, where item_id is not defined-the last line. ([STDERR] PHP Fatal error: Uncaught Error: Undefined constant "item_id" in /home/elightin/domains/elearnready.app/public_html/wp-content/themes/woodmart-one/single-class-profile.php:106)
$entry_table = $wpdb->prefix."frm_item_metas"; $entry_ids = $wpdb->get_results ( "SELECT item_id FROM $entry_table WHERE meta_value ='$sid' and field_id = '9'"); $entry_ids = json_decode(json_encode($entry_ids), True); $x = count($entry_ids) - 1; $entry = array(); for($i = $x; $i >= 0; $i--) { $entry = FrmProEntriesController::show_entry_shortcode(array( 'id' => $entry_ids[$i][item_id], 'format' => 'array'));
}
This code doesn't tell us anything. The error message says the error is coming from custom theme code: single-class-profile.php on line 106. It's not Formidable related. Please use pastebin or gist to post the entire single-class-profile.php file. Then come back and post a link to the patebin or gist.
We need to be able to see where item_id is being instantiated, if at all. Can you view the value of the $entry_ids variable? If item_id is meant solely as an array element key, you may just need to wrap item_id in straight quotes like this 'item_id'.
Thank you so much. I would never "guess" this solution (as you can see, I am not a programmer). Your suggestion fixed the issue! Can I buy you a cup of coffee?
Coffee's not necessary, thank you. Enjoy being part of this community.
I am glad that you are part of this community! Thanks again.
Please login or Register to submit your answer