anydes Posted April 25, 2019 Share Posted April 25, 2019 After recent updates to a wordpress site (updated non-related plugins, changed theme), the php code snippets are shooting back an error at the end of the feeds -- which were previously working fine for years. no other changes were made. Error Message: Quote Notice: Undefined variable: response in /nas/content/live/usafact/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(26) : eval()'d code on line 8 URL: https://usafact.org/benefit/vision-care-discounts/ PHP code: function do_post($url, $params) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $result = curl_exec($ch); curl_close($ch); return $response; } echo do_post("https://content.newbenefits.com/Feednocss.aspx", "hash=hDSJYjIb56KfGtxWE0I3OQ&Section=short_b2c"); The plugin developer said to replace $response with $result, but that did not work. Same error shows. Can someone please assist? Link to comment Share on other sites More sharing options...
chhorn Posted April 25, 2019 Share Posted April 25, 2019 As you have no `eval()` in your code, this message comes from somewhere else. That's not the handler.php you are showing. Link to comment Share on other sites More sharing options...
gw1500se Posted April 25, 2019 Share Posted April 25, 2019 Also note that the variable $response does not exist in that function. Whomever gave you that advice either didn't look at your code or does not know PHP. Returning $result was probably correct in the first place. As suggested by chhorn, the error is elsewhere in your code. Post the code from ' shortcode-handler.php '. Link to comment Share on other sites More sharing options...
ginerjm Posted April 25, 2019 Share Posted April 25, 2019 And please don't post ALL of the code - just the part near and around line 26. PS - Does the message REALLY look like what you posted, including the "eval()'d" part? Link to comment Share on other sites More sharing options...
anydes Posted April 25, 2019 Author Share Posted April 25, 2019 soory, i'm a noob to php development. where can i find the php handler? Link to comment Share on other sites More sharing options...
anydes Posted April 25, 2019 Author Share Posted April 25, 2019 here's the code from shortcode-handler.php. (from xyz insert php snippet plugin) here is screenshot of actual error message: Link to comment Share on other sites More sharing options...
gw1500se Posted April 25, 2019 Share Posted April 25, 2019 Just before the eval, echo $content_to_eval. There is something wrong with setting that variable. Link to comment Share on other sites More sharing options...
anydes Posted April 25, 2019 Author Share Posted April 25, 2019 thanks, gw1500se Any idea on how I can fix? Link to comment Share on other sites More sharing options...
gw1500se Posted April 25, 2019 Share Posted April 25, 2019 No. Maybe if you post what was echo'ed per my suggestion. Link to comment Share on other sites More sharing options...
anydes Posted April 26, 2019 Author Share Posted April 26, 2019 @gw1500se, i'm sorry i dont really know what you are suggesting? do you recommend I add code somewhere? If so, can you be more specific? Link to comment Share on other sites More sharing options...
gizmola Posted April 26, 2019 Share Posted April 26, 2019 You've made this really annoying by posting a screenshot rather than the code into a code block. In your screenshot go to the code on line #25 in your editor. Add a new blank line. For that blank line add this code: die('<pre>' . $content_to_eval . '</pre>'); Run the script, and it should output a string in a box. That is what was requested -- essentially the code the plugin is attempting to eval(). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.