help with include please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
katun
Forum Newbie
Posts: 5
Joined: Sun Aug 22, 2004 12:20 pm

help with include please

Post 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.
Cryptkeeper
Forum Newbie
Posts: 17
Joined: Wed Nov 10, 2004 3:05 am

Post 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.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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
Archy
Forum Contributor
Posts: 129
Joined: Fri Jun 18, 2004 2:25 pm
Location: USA

Post 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.
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post 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
Post Reply