• A page that been rendering properly, but now isn’t. When I place the source in a file outside of WP, it renders properly.

    — SOURCE:

    Thanks.
    
    <?php
    
    $ip = getenv(REMOTE_ADDR);
    $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $ipAddress = gethostbyname($_SERVER['SERVER_NAME']);
    
    print ('<font size="5" COLOR="#DC143C">Your IP address is: '.$ip.'.<p>Your host name is: '.$hostname.'.<p></font>');
    
    ?>

    –OUTPUT:

    Thanks

    $ip = getenv(REMOTE_ADDR);
    $hostname = gethostbyaddr($_SERVER[‘REMOTE_ADDR’]);
    $ipAddress = gethostbyname($_SERVER[‘SERVER_NAME’]);

    print (‘Your IP address is: ‘.$ip.’.

    Your host name is: ‘.$hostname.’.

    ‘);

    ?>

Viewing 6 replies - 1 through 6 (of 6 total)
  • Your PHP looks good and as you say, it works outside of WordPress, so that’s probably not the issue.

    When you say “a page” are you saying you had the PHP directly in the source code for a page in WordPress (which won’t work by itself), or did you have it in a custom template that a page was based on?

    Did you change anything between the time it was rendering properly and when I quit rendering?

    Are you getting any PHP errors?

    Thread Starter bobwp

    (@bobwp)

    The code in a Page in WP itself. It worked before, and I’m nearly certain I hadn’t modified it .

    I get no PHP error in a browser; do you mean a PHP error in a WP or server log?

    I wasn’t aware PHP doesn’t work in WP pages.

    Thanks much for your reply.

    As far as I know, you can’t run PHP directly by putting it in the editor of a Page, you would need to create a custom template, put the code in it, then set the Page to that template. It’s actually a security feature; you wouldn’t want any contributor or editor to be able to execute PHP on your site.

    Thread Starter bobwp

    (@bobwp)

    If I can’t use PHP in a default WP Page, I’ll have to rethink my strategy. My pages don’t allow commenting, but I could understand why WP might disallow PHP code in regular Pages, if doing so is a potential security opening.

    Thread Starter bobwp

    (@bobwp)

    I was reviewing my WP maintenance notes, and discovered I had previously installed a plugin: “Exec-PHP”. I apparently had deleted it at some point. I reinstalled, and all is well now. Sorry for not catching that earlier.

    That would do it. 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP code stopped rendering properly’ is closed to new replies.