Jump to content

echoing in wrong place


hackalive

Recommended Posts

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

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.