Include dosent work, can i use echo somehow ?

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

when i insert this file:
banners.php
(Open and refresh and you see the pic changes, one pic is empty too)

If i use banners.php as include in another file closer to root:

Code: Select all

<?php include "http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/banners.php";?>
It dosen't work.
(Cant see anything)


banner.php looks like this:

Code: Select all

<?php
srand ((double) microtime( )*1000000);
$numbanners = 7;
$banner = rand(0,$numbanners);
echo "<table align=center width=468 height=60><tr><td>";
include ("http://www.volunteerforum.se/Minmapp/Banners/Random/rotate_nr/$banner.tpl");
echo "</td></tr></table>";
?>
Even if i go one more step down and include the tpl file it dosent work:
(banners.php create so 1.tpl to 7.tpl shows one in a time random)

Code: Select all

<?php include "http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/1.tpl
";?>

And the code in the 1.tpl looks like this:

Code: Select all

<A href="http://www.barnhemmet.nu" target=_blank><IMG alt="Projekt Bagrationovsk" 
src="http://www.volunteerforum.se/Minmapp/Banners/Random/Bagrationovsk.gif" 
border=0></A>
And i see nothing...

So can i use echo on the file insted somehow ?
Or why dosen't it work ?
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
nesman
Miracle Worker
Miracle Worker
Posts: 1453
Joined: Thu Jan 15, 2004 8:17 am
Contact:

I'm not a php guru, but I think the include statement might be wrong. I think maybe instead of the http:// link, you should try the local filesystem link.

Code: Select all

<?php include "overallheader/RandomBanner/rotate_nr/banners.php";?>
Something like this, I think.
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

nesman wrote:I'm not a php guru, but I think the include statement might be wrong. I think maybe instead of the http:// link, you should try the local filesystem link.

Code: Select all

<?php include "overallheader/RandomBanner/rotate_nr/banners.php";?>
Something like this, I think.
Indeed, use the directory path (think of it from "the servers point of view"). Don't use http://
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

I have tried that too, dosen't work whit the php or tpl file.
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
nesman
Miracle Worker
Miracle Worker
Posts: 1453
Joined: Thu Jan 15, 2004 8:17 am
Contact:

Looking back, I see two different places that call for the http version of the file. banners.php and the file that calls to it. They both list the http version. Double check that they both only use the local path.

If that doesn't work, we can try a little test.

create a file "test.php"

Code: Select all

<?php
echo "hello world";
?>
Make sure that test.php works when you load it directly. After that works, drop it in the same folder as your main page, and try

Code: Select all

include test.php;
If that doesn't get you moving toward the solution, let us know.

btw: check your index.php or a few other random files and make sure that your include statements look close to what they're doing. I've even gone so far as to copy a working line of code into my code, and just changing out the important words when I had a problem caused by spaces. They shouldn't be a problem in php, but you get the point.



Edit:

I messed with it, just to make sure I wasn't talking total bs.

Check this page:
http://nesman.afraid.org/nes/Leon.php

you can see the source code here:
http://nesman.afraid.org/nes/Leon.php~

Also, there is the page that it calls to:
http://nesman.afraid.org/nes/hello.php

and (of course) the sourcecode:
http://nesman.afraid.org/nes/hello.php~

Reproduce these files on your server and see if that gets things moving.
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Yes that works:

Both files in this folder:
http://www.volunteerforum.se/overallheader/Test/

And it also works one folder down:
http://www.volunteerforum.se/overallhea ... e_code.php


It aslo worked in another folder from the root. but i had to use http:// then
or it diden't work :?

Code: Select all

<?php
    include ("http://www.volunteerforum.se/overallheader/Test/test_echo.php");
?>
Last edited by Leon on Mon Jun 26, 2006 11:53 pm, edited 1 time in total.
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

I created a file Test.php that has the include code (In the same folder)
Whit my script in question... (1 Pic is empty *transparent* so you might need to refresh)

Code: Select all

http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/test.php
Has the code:

<?php 
    include ("http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/banners.php"); 
?>
And this works.. but it will not work in the overall_header file

I also copied this file to another folder from root and it works:
It works like this. But it does not work when i inlude in the overall_header.tpl file..


I have also a testpage.tpl so i tried to add the code in that tpl file.
and same results there, it does not work..

Is it because of the tpl files it self somehow ?
Is it because the tpl file is not a php file or something ?
Is it impossibly to add php code in a tpl file ?
In that case how can it be fixed ?
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
nesman
Miracle Worker
Miracle Worker
Posts: 1453
Joined: Thu Jan 15, 2004 8:17 am
Contact:

Honestly, I don't know anything about tpl files. Never seen the inside of one. :)

Maybe rename the tpl file to php, just for testing? I'm assuming that tpl has about the same format as php (starts with <?php tag?).

I'll have to defer to Battye here.
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Yeee see what Battye says, because i cant change the name of the
overall_header. Or if i do i must redo almost every file on my page.
And i dont want that =P
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

I just heard that the tpl file was the problem, and that i need to
define some variables in the php file thats define the overall_header.tpl

Like:

Code: Select all

$template->assign_vars(array('USERFOOT' => "<br>".$resrow_conf['userfoot']."<br>");

$template->pparse('overall_header');
What ever he ment by that :?
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Leon wrote:I just heard that the tpl file was the problem, and that i need to
define some variables in the php file thats define the overall_header.tpl

Like:

Code: Select all

$template->assign_vars(array('USERFOOT' => "<br>".$resrow_conf['userfoot']."<br>");

$template->pparse('overall_header');
What ever he ment by that :?
By that, it means in the tpl file you put {USERFOOT} to output the variable :)
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Ok, but how do i include this file then as {USERFOOT} in the tpl file ?
http://www.volunteerforum.se/overallhea ... anners.php

or the code:

Code: Select all

<?php 
srand ((double) microtime( )*1000000); 
$numbanners = 7; 
$banner = rand(0,$numbanners); 
echo "<table align=center width=468 height=60><tr><td>"; 
include ("http://www.volunteerforum.se/Minmapp/Banners/Random/rotate_nr/$banner.tpl"); 
echo "</td></tr></table>"; 
?>
In include/page_header.php file. So i can add {USERFOOT} in the overall_header.tpl where i want it to show where i want...
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Bump
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Are you sure you want $banner.tpl ?

It means you could end up having 0.tpl, 1.tpl, 2.tpl, 3.tpl etc up to 7.tpl, not knowing which one.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Thats the idé. it should be randomized...

In the future i could create
banner1.php
banner2.php

And different folders for those files whit banner codes...
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Post Reply