Page 1 of 1
help with include please
Posted: Tue Nov 30, 2004 5:33 am
by katun
edit patrikG: use a descriptive title for your post and don't use CAPS or bold.
I HAVE THIS CODE:
<? include('include/promo.inc.php?pos=t'); ?>
AND THIS ERROR:
Warning: Failed opening 'include/promo.inc.php?pos=t' for inclusion
edit patrikG: use a descriptive title for your post and don't use CAPS or bold.
Posted: Tue Nov 30, 2004 5:44 am
by Cryptkeeper
Well, I don't know alot of php but I would remove the ?pos=t from your include and just type $pos=t in promo.inc.php.
Posted: Tue Nov 30, 2004 6:01 am
by phpScott
when you include a file you must pretend that all the code from the included file 'magically' appears from where you include it.
Code: Select all
<?php
$pos='t'
include('include/promo.inc.php');
?>
you are not passing variables to it.
[php_man]include[/php_man]
btw: don't be supprised if a mod say use the php tags for code. that little button that says 'php' on it
Posted: Tue Nov 30, 2004 6:30 am
by Archy
I was aware that you could pass variables if you used the whole URL, eg:
Code: Select all
include('http://www.foo.com?pos=t');
I could however be wrong, I havent checked this out.
Posted: Tue Nov 30, 2004 9:12 am
by protokol
When including local files, you can return values from an [php_man]include[/php_man](), but you may need to think of a better way to get variables set in them. Since [php_man]include[/php_man]() simply includes all the contents of the file into the place that it is called at, you can set variables above it which will be in the
scope