Forum Moderators: coopster

Message Too Old, No Replies

PHP Include() Outputs HTML Wrong Place

PHP Include Displays Content Above Header Not In Body

         

Mickie

10:45 am on Mar 12, 2009 (gmt 0)

10+ Year Member



hello:

i've been at this for days, help would be appreciated.

the following piece of code is a new page i'm trying to add to a back office menu link. i'm using the include() function to call an HTML file.

i've tested many variations of this & the include function output will only appear ABOVE my header, not in the BODY (content) of the page. i've done all within my knowledge to fix/force it to appear in the body of the page, but it either won't show or produces an error.

not sure what i'm missing or even if i can add something to the css to correct the positioning. thanks in advance.

<?php

.........(600 pages)...............

elseif($action=="promotools"){
# =========================
# Show Promotion Tools
# =========================

$folder = str_replace("dashboard.php", "", $_SERVER["PHP_SELF"]);
$title = "Promo Tools";
$body = "
$menu <p align=center> Your Unique Referral Link Is: <input type=text size=50
value='http://$sys_domain$folder?affid=$user[id]'> </p>"; include("emotools.htm");

showPage($title, $body);
exit;
}

blang

11:02 am on Mar 12, 2009 (gmt 0)

10+ Year Member



Based on what I see, the showPage() function outputs the title and body passed to it (and likely builds the HTML for the rest of the document). If you include the "emotools.htm" document prior to that function call, it will be included first. You have to find a way to incorporate the include statement within that function call (maybe pass the file name as a third parameter to your custom function?) or else find a different way to output the data.

Jsyvanne

11:18 am on Mar 12, 2009 (gmt 0)

10+ Year Member



Perhaps you could do something like this?:

...
$body = "$menu <p align=center> Your Unique Referral Link Is: <input type=text size=50
value='http://$sys_domain$folder?affid=$user[id]'> </p>";

ob_start();
include('emotools.html');
/* echoes the html like it did before, but this time into output buffer, instead of blurting it out before showPage() function call */

$body .= ob_get_contents(); /* add the buffer to your body */
ob_end_clean();

showPage($title,$body);
...

blang

1:40 pm on Mar 12, 2009 (gmt 0)

10+ Year Member



Hey Jsyvanne, welcome to the forum.

Yes, using the output buffer is another idea.

Mickie

7:55 pm on Mar 12, 2009 (gmt 0)

10+ Year Member



hello Jsyvanne SOLUTION AT LAST!

blang, thank you for responding, followed your suggestions but - no go, results as follows:

- inserted before $body variable (no change - stills appears above header, outside of function)

- inserted before/after $folder variable (same response)

- inserted as 1st command in $body variable function(produced Parse error syntax error, unexpected T_STRING)

the thing is when i tried to include it in the $body function (which is where it should go, it produced an error).

Jsyvanne YOU ROCK! your suggestion is what did it, your instructions were clear & to the point (much thanks for that). results as follows:

- inserted your output buffer, as follows (without comments),
______________

$body = "$menu <p align=center> Your Unique Referral Link Is: <input type=text size=50
value='http://$sys_domain$folder?affid=$user[id]'> </p>";

ob_start();
include('emotools.htm');
$body .= ob_get_contents(); ob_end_clean();

showPage($title, $body);
_______________

AND THE CLOUDS PARTED! LOL!

much appreciation to you both,
mic