SJF Posted July 5, 2009 Author Share Posted July 5, 2009 Interestingly enough, when I test this on another server with another site I did, and used the original include (which works fine on that server) it works fine when including two pages. This is what works, to show both pages, on the previous site. <?php include("http://www.theirsite.com/content/?p=95"); ?> <?php include("http://www.theirsite.com/content/?p=228"); ?> But when I do the same exactly thing with the code you gave me... via: <?php $_GET['p'] = 95; $WPdir = dirname(__FILE__)."/content"; chdir($WPdir); include($WPdir."/index.php"); ?> <?php $_GET['p'] = 228; $WPdir = dirname(__FILE__)."/content"; chdir($WPdir); include($WPdir."/index.php"); ?> ...it doesn't show the second included post. So somehow the code you gave me and the one that is working isn't matching to call the same things from the server. Quick question, since I'm a newb at PHP here, when the URL says "?p=228" at the end of it, the only way of calling that variable p is via a $_GET? I'm just trying to narrow it down. Hope this helps some. (I can not link since I don't have their permission to) Quote Link to comment https://forums.phpfreaks.com/topic/164787-solved-php-include-not-working-server-side/page/2/#findComment-869454 Share on other sites More sharing options...
MadTechie Posted July 5, 2009 Share Posted July 5, 2009 Yes P=228 is $_GET['p'] = 228 WP has code that stops it loading twice,, the old code connects to itself by going out then back in, and opens 2 connections, where as a normal include doesn't go out, *thinking of options* Let me install WP on my local PC and I'll have a look Quote Link to comment https://forums.phpfreaks.com/topic/164787-solved-php-include-not-working-server-side/page/2/#findComment-869459 Share on other sites More sharing options...
SJF Posted July 5, 2009 Author Share Posted July 5, 2009 Hmm alright, thanks, I appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/164787-solved-php-include-not-working-server-side/page/2/#findComment-869460 Share on other sites More sharing options...
MadTechie Posted July 5, 2009 Share Posted July 5, 2009 okay new idea, try this <?php $WPdir = dirname(__FILE__)."/content"; chdir($WPdir); require_once("adapter.php"); echo getPost(95); echo getPost(228); ?> adapter.php must be in the WP folder <?php require('wp-config.php'); mysql_connect(DB_HOST,DB_USER,DB_PASSWORD); mysql_select_db(DB_NAME); function getPost($id) { $vars = mysql_query(sprintf("SELECT post_content FROM wp_posts WHERE post_status = 'publish' AND ID = %d", $id) ); $row = mysql_fetch_assoc($vars); return $row['post_content']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/164787-solved-php-include-not-working-server-side/page/2/#findComment-869467 Share on other sites More sharing options...
SJF Posted July 5, 2009 Author Share Posted July 5, 2009 I ain't kiddin' when I say you're an effin genius. It worked perfectly. Thank you! Now I owe you 2 drinks!! edit: (topic solved - for now! haha and hopefully forever!) Quote Link to comment https://forums.phpfreaks.com/topic/164787-solved-php-include-not-working-server-side/page/2/#findComment-869468 Share on other sites More sharing options...
MadTechie Posted July 6, 2009 Share Posted July 6, 2009 Cool again this was my third option, create an adapter, please note I am very new to WP (as in about an hour new) so it may not cover everything but from an overview I think it should cover the main part (getting the post) things like comments etc are not included but can be added. i hope it works for you Quote Link to comment https://forums.phpfreaks.com/topic/164787-solved-php-include-not-working-server-side/page/2/#findComment-869472 Share on other sites More sharing options...
SJF Posted July 6, 2009 Author Share Posted July 6, 2009 Yea it's all good. I won't need comments, etc. It's just for content managing. Thanks again! You might be interested in this site - www.chipin.com maybe put it on your signature? People can give you money for thanks! Haha, instead of a "buy a drink" button! I'll throw a couple dollars your way! Quote Link to comment https://forums.phpfreaks.com/topic/164787-solved-php-include-not-working-server-side/page/2/#findComment-869601 Share on other sites More sharing options...
MadTechie Posted July 6, 2009 Share Posted July 6, 2009 You know someone paypaled me lunch money, that was kinda funny. when i saw it! Quote Link to comment https://forums.phpfreaks.com/topic/164787-solved-php-include-not-working-server-side/page/2/#findComment-869764 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.