include in PHP carry over variables?

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
MattSharp
Forum Commoner
Posts: 62
Joined: Wed Apr 24, 2002 2:25 pm

include in PHP carry over variables?

Post by MattSharp »

When you do include(filename) shouldnt the variables from the included file work on the file with include in it?
User avatar
martin
Forum Commoner
Posts: 33
Joined: Fri Jun 28, 2002 12:59 pm
Location: Cambridgeshire

Post by martin »

Yes they should. Could the problem be with trying to use variables in functions?
MattSharp
Forum Commoner
Posts: 62
Joined: Wed Apr 24, 2002 2:25 pm

Post by MattSharp »

No. One is a loop control variable and the other are the username and password for logging into a mySQL database.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What exactly is the problem you are having? Do you have any code you could show us so that we can help?

Mac
MattSharp
Forum Commoner
Posts: 62
Joined: Wed Apr 24, 2002 2:25 pm

Post by MattSharp »

I seem to be having the problem when I include a file from another directory. Any more help?

Here is hte line:

Code: Select all

require("http://www.drivingwithflats.com/news/config.php");
Hmm, could it be cause of multplie includes? Cause the file that config is being included in is in the same directory, but then that file is being included in a another directory? Its a tangled web, aint it?
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

try

Code: Select all

require_once("http://www.drivingwithflats.com/news/config.php");
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You still haven't actually said what the problem is. Is there an error message or is code just not working as expected, if so what does it do and what did you expect. If it is a problem with including files multiple times, require_once() or include_once() should solve that as hob_goblin said.

Mac
Post Reply