Page 1 of 2 12 LastLast
Results 1 to 25 of 35
  1. #1
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Plugin to Insert PHP into WordPress Posts
    I don't think WP allows this by default so does anyone know of a good plugin that allows insertion of php code into WP posts?

  2. #2
    ABW Ambassador
    Join Date
    January 18th, 2005
    Location
    Nunya, Business
    Posts
    23,684

  3. #3
    Full Member gcarson's Avatar
    Join Date
    November 13th, 2009
    Posts
    383
    Quote Originally Posted by Trust View Post
    +1. Never had any issues with it. Can execute php in posts, widgets, pages, etc etc.

  4. #4
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Thanks

  5. #5
    ABW Ambassador writerguy's Avatar
    Join Date
    January 17th, 2005
    Location
    Springfield, Missouri, USA
    Posts
    3,248
    Yup. Exec-PHP is the way to go.
    Generate more fake news.

  6. #6
    ABW Ambassador meadowmufn's Avatar
    Join Date
    January 18th, 2005
    Location
    Seattle
    Posts
    2,587
    +1

    Just be sure to do everything in HTML view and NOT Visual. Otherwise, things might get screwed up.
    -Don't criticize anyone til you've walked a mile in their shoes. Then when you do criticize them, you'll be a mile away and have their shoes.
    - Silence is golden. Duct Tape is silver.

  7. #7
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Trying to add some php code now and it looks like you have to include <?php ?> around every single line you add? I was hoping to do the open <?php followed by multiple lines of php and then end with ?>.

    Something seems strange.

  8. #8
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Still am getting an error that says....

    Parse error: syntax error, unexpected '>' in /home/xxxxxxx/public_html/xxxxxxx/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 3

  9. #9
    ABW Ambassador writerguy's Avatar
    Join Date
    January 17th, 2005
    Location
    Springfield, Missouri, USA
    Posts
    3,248
    I've never had to add the php tags around code I insert.

    Are you sure you're adding the code in the HTML editing tab within WP and not in the visual editor tab? That would make a difference, probably, as meadowmufn suggested above.
    Generate more fake news.

  10. #10
    ABW Ambassador
    Join Date
    January 4th, 2006
    Location
    USA
    Posts
    2,477
    Quote Originally Posted by SeymourButts View Post
    I was hoping to do the open <?php followed by multiple lines of php and then end with ?>.

    Something seems strange.
    Open <?php ?>. should work.

    Try delete and re-install the plugin. That's what I do when strange things happen.

  11. #11
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    I am definitely in html mode. I actually have the visual editor turned off for my id.

  12. #12
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    If I do something like this it works fine...
    Code:
    <?php echo "hello"; ?>
    If I do something like this, I get that error...
    Code:
    <?php 
    echo "hello"; 
    echo "goodbye";
    ?>

    And If I do something like this, it's' ok...
    Code:
    <?php echo "hello"; echo "goodbye"; ?>
    The php code can only span a single line?

  13. #13
    ABW Ambassador writerguy's Avatar
    Join Date
    January 17th, 2005
    Location
    Springfield, Missouri, USA
    Posts
    3,248
    Quote Originally Posted by SeymourButts View Post
    If I do something like this it works fine...
    Code:
    <?php echo "hello"; ?>
    If I do something like this, I get that error...
    Code:
    <?php 
    echo "hello"; 
    echo "goodbye";
    ?>

    And If I do something like this, it's' ok...
    Code:
    <?php echo "hello"; echo "goodbye"; ?>
    The php code can only span a single line?
    Truly bizarre. I've never had an issue putting PHP code into a WP post or page using this plugin that I can recall.

    I tried Googling the error message you gave a couple of posts above. I don't understand enough PHP to be able to figure out what I found. BUT -- in one forum post where someone reported the error message like that, he resolved the issue by putting some escape code around something in his PHP coding.

    Could it be you have some sort of characters in the code you're inserting that need to be escaped? (I think that means putting the \ before or after them, right? I'm pretty PHP incoherent/illiterate. LOL!)

    Could there be something wrong with the PHP code you're trying to insert? Based on your error message, have you gone into the EXEC-PHP plugin and looked at and around line 3 to see what that looks like? Sometimes that'll give you a clue?

    But, wow, I've never had a problem before so I'm afraid other than suggesting you go to the plugin's website and look around, I really don't have a clue??
    Generate more fake news.

  14. #14
    Beachy Bill's Avatar
    Join Date
    November 20th, 2005
    Posts
    8,266
    It may be a theme-specific conflict. Try switching to another theme or two and give it a whirl. That's the only thing I can think of. Ive done well with the EXEC-PHP plug-in used in some themes, but do recall having problems with another. It always worked for me in the ol' default, Kubrick. YMMV
    Bill / Marketing Blog @ 12PM - Current project: Resurrecting my "baby" at South Baltimore..
    Cute Personal Checks and Business Checks
    If you are too busy to laugh you are too busy.

  15. #15
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Here is the function that complains (on the eval() )...
    Code:
    function eval_php($content)
    	{
    		// to be compatible with older PHP4 installations
    		// don't use fancy ob_XXX shortcut functions
    		ob_start();
    		eval("?>$content<?php ");
    		$output = ob_get_contents();
    		ob_end_clean();
    		return $output;
    	}

  16. #16
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Well, it looks like I will uninstall this plugin since I can't use it to pull some records from a datafeed to display inside the post.

    On the other hand, it works great if you want to say "hello".

  17. #17
    Analytics Dude Kevin's Avatar
    Join Date
    January 18th, 2005
    Location
    Rochester, NY
    Posts
    5,904
    Seymour: I've used it to paste Avantlink's PhP dynamic pagemaker stuff before. I've never had an issue with it.

    Is there something missing on your server maybe that is needed to have that run right? Not sure if it has any requirements.
    Kevin Webster
    twitter: levelanalytics

    Kayak Fishing
    Web Analytics and Affiliate Marketing

  18. #18
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Quote Originally Posted by Kevin View Post
    Seymour: I've used it to paste Avantlink's PhP dynamic pagemaker stuff before. I've never had an issue with it.

    Is there something missing on your server maybe that is needed to have that run right? Not sure if it has any requirements.
    I have a handful of sites that all run php without issue on the same server.

  19. #19
    Analytics Dude Kevin's Avatar
    Join Date
    January 18th, 2005
    Location
    Rochester, NY
    Posts
    5,904
    Understood. Some plugins require additional settings, or ionCube, or other stuff to function properly. i don't remember that for Exec PHP though.
    Kevin Webster
    twitter: levelanalytics

    Kayak Fishing
    Web Analytics and Affiliate Marketing

  20. #20
    ABW Ambassador
    Join Date
    January 4th, 2006
    Location
    USA
    Posts
    2,477
    Seymour, it looks more like a theme issue. Have you tried to switch to the WP default theme and see if the problem still exist? If your codes work fine with the default theme, then you can work on fixing the theme you are using right now.

  21. #21
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    When I log the $content from the complaining eval_php function, I see extra line breaks and paragraph tags included. I wonder if that is the problem.
    Code:
    <p><?php<br />
    //my php code here
    ?></p>

  22. #22
    ABW Ambassador ladidah's Avatar
    Join Date
    October 15th, 2007
    Location
    MA
    Posts
    1,888
    Did you enclose the php with the <phpcode> </phpcode> in the html format like this?

    <phpcode>
    <?php

    <!-- code goes here -->

    ?>
    </phpcode>

  23. #23
    ABW Ambassador writerguy's Avatar
    Join Date
    January 17th, 2005
    Location
    Springfield, Missouri, USA
    Posts
    3,248
    Quote Originally Posted by ladidah View Post
    Did you enclose the php with the <phpcode> </phpcode> in the html format like this?
    That's not necessary at all with EXEC-PHP plugin when putting code into WP. I think maybe it used to be several versions of the plugin ago. But I've never had to do that on any of my sites.
    Generate more fake news.

  24. #24
    ABW Ambassador ladidah's Avatar
    Join Date
    October 15th, 2007
    Location
    MA
    Posts
    1,888
    I just checked with one of my new blogs that I just put up this past 2 weeks, and I needed those tags. However, if I didn't have it, it did not give me that funky error but the php did not work.

    So when I enclose the php code with that tag, it works!

  25. #25
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    The phpcode tags didn't make a difference. I think some extra data is getting put into the text by something.

    Parse error: syntax error, unexpected '>' in

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: June 2nd, 2011, 11:56 PM
  2. Popshops Wordpress plugin and PHP
    By lostdeviant in forum PopShops
    Replies: 19
    Last Post: January 10th, 2008, 08:26 AM
  3. PHP MySQL Bulk Insert
    By popdawg in forum Programming / Datafeeds / Tools
    Replies: 4
    Last Post: March 4th, 2006, 12:25 AM
  4. How do I insert a PHP script into a .htm file
    By dak142 in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: April 2nd, 2004, 06:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •