Jump to content

Why do files using the 'include' function always appear at the top of the page?


jpmad4it

Recommended Posts

Hello everyone,

 

I am having trouble with an include file. The file that I am including in my web page controls a random flash banner rotator. All that you have to do is add the following to the page and the banner is displayed:

 

<? php include("http://www.xxxxxxx.com/yyyyyyy"); ?>

 

The problem I have is that the flash banner always appears at the very top of the page, but it should be appearing where it is told to, which is half way down the page within a table I have set out.

 

I have tried the following but I get the same result:

 

<?php $file = file_get_contents("http://www.xxxxxxxx.com/yyyyyyyy"); 
echo $file; ?>

 

Can anyone help? Are include files automatically set to appear at the top of the page? Am I missing something?

 

Any suggestions would be greatly appreciated.

 

Regards Jp  ???

Link to comment
Share on other sites

its because you have it outputting data before any of your html.

 

all you need to do is place the

 

<?php $file = file_get_contents("http://www.xxxx.com/banners"); 
echo $file; ?>

 

inside a suitable element in your site. where ever you want it to display simply put that bit of code inside the relevant td tag

Link to comment
Share on other sites

Its very hard to explain how its all set out. I guess anyone familiar with the Cubecart software would know best. The following code is included in the english language folder, in a file which is called home.inc.php, so I guess that its an include file in its own right. It has the follwoing code:

 

<?php
$home['copy'] = '<p align=\"center\"><strong><font size=\"3\">CHECK THIS OUT........ INTRODUCING<br/>
GOODGREEF&#39;s BRAND NEW "MADE TO ORDER" PRODUCT RANGE</font></strong></p>
<p align=\"center\"><font size=\"2\">The Goodgreef Team have come up with yet another ingenious idea. This gives you loyal clubbers a chance to get hold of certain items that we have not been able to offer before! So what are you waiting for! Check the items out today!</font></p>';
$home['copy'] = '<p align=\"center\">' ?> <?php include("http://www.goodgreef.com/banners"); ?> <?php '</p>';
$home['enabled'] = '1';
$home['title'] = 'Welcome to the Goodgreef Shop';
?>

 

I can't even start to think to explain how it all works!! I'll have to have a look and see if I can try to explain it.

 

regards jp

Link to comment
Share on other sites

The problem is this line:

<?php
$home['copy'] = '<p align=\"center\">' ?> <?php include("http://www.xxx.com/banners"); ?> <?php '</p>';
?>

I believe what you are trying to do is put the contents of the included file into the array. The following should do that:

<?php
$file = file_get_contents("http://www.xxx.com/banners"); 
$home['copy'] = '<p align=\"center\">' . $file . '</p>';
?>

 

Ken

Link to comment
Share on other sites

The problem is this line:

<?php
$home['copy'] = '<p align=\"center\">' ?> <?php include("http://www.xxx.com/banners"); ?> <?php '</p>';
?>

I believe what you are trying to do is put the contents of the included file into the array. The following should do that:

<?php
$file = file_get_contents("http://www.xxx.com/banners"); 
$home['copy'] = '<p align=\"center\">' . $file . '</p>';
?>

 

Ken

 

SUPERSTAR! It works. Thanks!

 

EDIT - ahhhh now I can only have the banner OR the text in that array, and not both  ???

 

EDIT2: I fixed it guys. Thanks for the help .......... ***** five star rating!

Link to comment
Share on other sites

  • 2 weeks later...
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.