MyBB Community Forums

Full Version: Inserting PHP into the footer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I'm using an advertisement rotation script in my footer but nothing is showing up. The script is

<?php

$fcontents = join ('', file ('banner_ads.txt'));
$s_con = split("~",$fcontents);

$banner_no = rand(0,(count($s_con)-1));
echo $s_con[$banner_no];
?>

Please help!
You can't use the codes this way in MyBB.

However to make things easy for you, i recommend using Easy Adv. Banner 2.0 for fresh banner with each page load.

regards
You can't do it like that, you would have todo it like this. add to your global.php script.
$fcontents = join ('', file ('banner_ads.txt'));
$s_con = split("~",$fcontents);

$banner_no = rand(0,(count($s_con)-1));
$banner = $s_con[$banner_no];
And then add $banner to your template.
CraKteR Wrote:You can't do it like that, you would have todo it like this. add to your global.php script, or in the file you want it to display in.

And then add $banner to your template.

In global.php, make sure you put the code before:
eval("\$footer = \"".$templates->get("footer")."\";");
Why can't I just enter the PHP in the template?

Also, where do I put it in global.php? This is all so confusing, I hardly know any PHP whatsoever...

[Edit] Nevermind, I got it working...
You can't enter PHP into the templates because they are hard-coded HTML with the addition of MyBB variables.

All PHP must beentered into the files.