Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Blogs and Blogging (http://www.greenguysboard.com/board/forumdisplay.php?f=8)
-   -   executing php in a wordpress blog post? (http://www.greenguysboard.com/board/showthread.php?t=44644)

spacedog 2007-12-28 03:57 PM

executing php in a wordpress blog post?
 
I'd like to execute php in a wordpress blog post but can't get it to work.

I tried two different plugins, neither of them work.

exec php & run php.

With exec php after entering code between the tags it just shows the code in the post instead of showing what the code is telling it to show.

Anyone know a way to solve this?

LD 2007-12-28 05:21 PM

Same problem here. I can give you a couple of others to try...didn't work for me, but maybe you'll have better luck.

http://www.daikos.net/widgets/daikos-text-widget/

http://www.erik-rasmussen.com/blog/2...tize-anything/

I'm trying to drop in some php from Dragonscrips, and it just says "cannot connect to server"

If you figure it out, let me know...

walrus 2007-12-28 06:00 PM

I run exec.php and am able to add php to pages without any problem. have never tried posts but can't imagine it would be different.

Useless 2007-12-28 06:17 PM

Quote:

Originally Posted by walrus (Post 381699)
I run exec.php and am able to add php to pages without any problem. have never tried posts but can't imagine it would be different.

That's what I've used and works fine within posts. I believe it's another situation in which you want to turn off the Visual Rich Editor.
http://bluesome.net/post/2005/08/18/50/

walrus 2007-12-28 06:40 PM

Quote:

Originally Posted by Useless Warrior (Post 381705)
That's what I've used and works fine within posts. I believe it's another situation in which you want to turn off the Visual Rich Editor.
http://bluesome.net/post/2005/08/18/50/

Or, in other words, read the fucking manual

spacedog 2007-12-28 08:22 PM

Quote:

Originally Posted by walrus (Post 381708)
Or, in other words, read the fucking manual

yep. did everything it said.. even installed the role manager, etc..

tried several times & nothing works.. not in a post nor as a page.

I have tgp on root & blog in dir.

Script is in root & trying to include tgp script in post thats on blog in dir as

Code:

 include("../script.php");
 $query  = "SELECT COUNT(url) AS numrows FROM links";
 $result  = mysql_query($query) or die('Error, query failed');
 $row    = mysql_fetch_array($result, MYSQL_ASSOC);
 $numrows = $row['numrows'];
 
 $maxPage = ceil($numrows/65);

 $sql = "SELECT url, title, date FROM `links` ORDER BY date DESC LIMIT ".$offset.", 65;";
 $rs = mysql_query($sql);
 echo mysql_error();
 
 
 $self = $_SERVER['PHP_SELF'];
 $nav = '';
 for($page = 1; $page <= $maxPage; $page++)
 {
    if ($page == $pageNum)
    {
        $nav .= " $page ";
    }
    else
    {
        $nav .= " $page ";
    }
 }

while($row = mysql_fetch_row($rs)){
    echo "".$row[1]."".$row[2]."\n\n";}

 echo "

Page: ";
 $self = $_SERVER['PHP_SELF'];
 $nav = '';
 for($page = 1; $page <= $maxPage; $page++)
 {
    if ($page == $pageNum)
    {
        $nav .= " $page ";
    }
    else
    {
        $nav .= " $page ";
    }
 }

echo $first . $prev . $nav . $next . $last;
 mysql_close();
?>


and I end up with on the post
Code:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ 65′ at line 1
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /dirname/0/blahblah/htdocs/file/name/wp-content/plugins/exec-php/runtime.php(41) : eval()’d code on line 29


Useless 2007-12-28 10:46 PM

In the docs, the author states:
Quote:

If you experience a PHP error message like 'Some error in /home/minime/htdocs/blog/wp-content/plugins/exec-php/runtime.php(41) : eval()’d code on line 4' then it's time to repair your PHP code. If you are unsure where your code breaks, first run it in a separate file to punch out all bugs and afterwards copy the code into your article or widget.
So I guess he's saying, "it's you, not me." ;)

I'm not a PHP guru, so I really couldn't tell you what's wrong with the included script's code.

spacedog 2007-12-29 10:50 AM

Quote:

Originally Posted by Useless Warrior (Post 381723)
In the docs, the author states:So I guess he's saying, "it's you, not me." ;)

I'm not a PHP guru, so I really couldn't tell you what's wrong with the included script's code.


The code works fine on a normal php page. Must be some conflict with wordpress & the plugin and I don't know how to fix this as I didn't write this code

walrus 2007-12-29 02:28 PM

It's more than likely a pathing problem in the code. Wordpress is a bit unique in that a post resides within the theme and the path through there would be through your theme.

Try using absolute instead of relative paths and you may be ok.


All times are GMT -4. The time now is 11:10 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc