hackalive Posted April 2, 2010 Share Posted April 2, 2010 Hi guys, I have an index.php page which run some code and executes a few functions which should echo it in a certain location, instead it continues to echo in the top left of the index.php echothis.php (file that should be echoed to certain location) <?php echo $_SESSION['login_to']; ?> <h4>WLWW</h4> function2.php (file calling the function whcih call for insert purposes echothis.php <?php function insertt(){$require_once = $_SERVER['DOCUMENT_ROOT'].'/echothis.php'; require_once($require_once); } ?> function1.php (calls function2.php where needed) <?php function go(){ insertt();?> index.php <H4>WELCOME</H4><?php go(); ?> I have left out the top require require_onces for the files but as you can see index.php require_onces function1.php, function1.php calss function2.php and function2.php echothis.php any help is much appreciated Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 so what is the "correct" way to do this Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted April 2, 2010 Share Posted April 2, 2010 I dunno, but to me thats looks like a lot of calling this that and the other for no reason what so ever. Why not instead where ever you want this particular session to display try <?php if(isset($_SESSION['login_to'])){echo $_SESSION['login_to'];}else{echo "some alternative as the session isn't set"} ?> Just a thought, I don't know what your particularly doing, and what other stuff you have in your files other than you showed here.. but sessions are like cookies, and the easiest way I can think to describe them is they float in mid air and you can pluck them down when ever, just like cookies except they store on the server side, not the client side or something like that.. Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 monkeytooth thanks for your help but unfortuanately I cannot use your code, so if anyone else has any ideas Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 in essence I want to call a PHP file which is like an "app" with tables etc (whatever I write) into my CMS on the relevant page, so if there are any better ways people can suggest Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 for some stupid reason it is echoing before it compiles it all together with the other code Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 I have no idea how to do this, but I am thinking what if I convert the echothis.php to HTML so not (or maybe I have no idea) have require_once('echothis.php) and have phphtml('echothis.php') and even if this is not a viable solution for this problem I would like to know if such a PHP function exists thanks The require_one is making the content display early so I need another way of calling, that is the problem, or at least part of Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 having function.php as return "AAA"; instead of with require_once places the contents in the right spot, so I need to do something other than require_once in order to dsiplay the whole page Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 I have done a bit more fiddiling and it is definetly becuase of the require_once so I need a new way of doing this Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 someone must have an idea? Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 2, 2010 Share Posted April 2, 2010 I understand you need help with this. But PLEASE do not bump messages. It is annoying. but in index.php, why dont you just call insertt() instead of go first? It's stupid. Also, I'll need some more of your index.php to find out where the echo is being displayed, and where it should be. Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 TeddyKiller I appreciated what you are saying but is there a way to get a file other than using require_once, the file structure must remain as is, just need a new way for require_once Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 2, 2010 Share Posted April 2, 2010 include() Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 include yields the same result as require Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 2, 2010 Share Posted April 2, 2010 Then remove your require or whatever, and put in the echo directly the function. What can go wrong? Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 2, 2010 Author Share Posted April 2, 2010 SOLVED and incase anyone everneeds it in the future where I had require_one do this instead http://www.acuras.co.uk/articles/88-php-include-a-file-and-store-contents-to-variable-using-output-buffer Thanks to everyone who offered adive and help Quote Link to comment 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.