• Resolved geowil

    (@geowil)


    Hello, I am attempting to use your plugin to inject some PHP/HTML coding into a page on our WP site but I am running into the following error when trying to view the page:

    Notice: Undefined index: err in /var/www/html/wp-content/plugins/insert-php/includes/shortcodes.php(66) : eval()’d code on line 1

    Fatal error: Uncaught Error: Call to undefined function IsEmpty() in /var/www/html/wp-content/plugins/insert-php/includes/shortcodes.php(66) : eval()’d code:3 Stack trace: #0 /var/www/html/wp-content/plugins/insert-php/includes/shortcodes.php(66): eval() #1 /var/www/html/wp-content/plugins/insert-php/libs/factory/shortcodes/shortcode.class.php(287): WINP_SnippetShortcode->html(Array, ”) #2 /var/www/html/wp-content/plugins/insert-php/libs/factory/shortcodes/shortcodes.php(97): Wbcr_FactoryShortcodes324_Shortcode->render(Array, ”) #3 /var/www/html/wp-includes/shortcodes.php(319): Wbcr_FactoryShortcodes324_ShortcodeManager->__call(‘shortcode_WINP_…’, Array) #4 [internal function]: do_shortcode_tag(Array) #5 /var/www/html/wp-includes/shortcodes.php(197): preg_replace_callback(‘/\\[(\\[?)(wbcr_p…’, ‘do_shortcode_ta…’, ‘<style type=”te…’) #6 /var/www/html/wp-content/plugins/js_composer_theme/include/helpers/helpers.php(236): do_shortcode(‘<style type=”te…’) #7 /var/www/html/wp-content/plugins/js_composer_theme/inclu in /var/www/html/wp-content/plugins/insert-php/includes/shortcodes.php(66) : eval()’d code on line 3

    Have you created the parser to handle inline php if-ing correctly? Here is my snippet:

    if ($_GET['err'] === "LoginErr") : ?>
        <label style="display: block; font-size: 18px; font-weight: bold;">Username or password incorrect, or the username was not found.  Please try again or ask for assistance.</label>
    <?php elseif (!IsEmpty($_GET['err'])) : ?>
        <label style="display: block; font-size: 18px; font-weight: bold;">An unexpected error has happened.  Please notify the instructor.<br/><br/>  Error Message: <?php echo $_GET['err']; ?></label>
    <?php else : ?>
    <?php endif;

    If I drop this into a non-Wordpress page and add in the first opening and last closing tags it works.

    • This topic was modified 7 years, 3 months ago by geowil.
    • This topic was modified 7 years, 3 months ago by geowil.
    • This topic was modified 7 years, 3 months ago by geowil.
    • This topic was modified 7 years, 3 months ago by geowil.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter geowil

    (@geowil)

    Nevermind, I go it.

    It occurred to me after posting that if WordPress does stupid parsing, it is not intelligent (HUGE design flaw if you ask me), it would cause this. It looks for the parameter without checking if it actually exists first which is why it was throwing out that err did not exist.

    So I have changed my code to this and it is working perfectly.

    if (isSet($_GET['err']) && !Empty($_GET['err']) && $_GET['err'] === "LoginErr") : ?>
        <label style="display: block; font-size: 18px; font-weight: bold;">Username or password incorrect, or the username was not found.  Please try again or ask for assistance.</label>
    <?php elseif (isSet($_GET['err']) && !Empty($_GET['err'])) : ?>
        <label style="display: block; font-size: 18px; font-weight: bold;">An unexpected error has happened.  Please notify the instructor.<br/><br/>  Error Message: <?php echo $_GET['err']; ?></label>
    <?php else : ?>
    <?php endif; 

    Great plugin to add something that WordPress should have by default.

    • This reply was modified 7 years, 3 months ago by geowil.
    • This reply was modified 7 years, 3 months ago by geowil.
    • This reply was modified 7 years, 3 months ago by geowil.

    Hi
    I’m glad you figured it out.

    Best regards

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Inline PHP If/Elseif/Else statement Help’ is closed to new replies.