Page 1 of 2

Include dosent work, can i use echo somehow ?

Posted: Mon Jun 26, 2006 12:30 pm
by Leon
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 ?

Posted: Mon Jun 26, 2006 12:58 pm
by nesman
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.

Posted: Mon Jun 26, 2006 1:32 pm
by battye
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://

Posted: Mon Jun 26, 2006 3:52 pm
by Leon
I have tried that too, dosen't work whit the php or tpl file.

Posted: Mon Jun 26, 2006 9:41 pm
by nesman
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.

Posted: Mon Jun 26, 2006 11:34 pm
by Leon
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");
?>

Posted: Mon Jun 26, 2006 11:41 pm
by Leon
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 ?

Posted: Tue Jun 27, 2006 2:41 am
by nesman
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.

Posted: Tue Jun 27, 2006 10:10 am
by Leon
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

Posted: Tue Jun 27, 2006 12:45 pm
by Leon
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 :?

Posted: Tue Jun 27, 2006 1:05 pm
by battye
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 :)

Posted: Tue Jun 27, 2006 1:43 pm
by Leon
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...

Posted: Thu Jun 29, 2006 10:49 pm
by Leon
Bump

Posted: Fri Jun 30, 2006 10:35 am
by battye
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.

Posted: Fri Jun 30, 2006 10:44 am
by Leon
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...