Page 1 of 1
include in PHP carry over variables?
Posted: Sun Jul 07, 2002 9:42 pm
by MattSharp
When you do include(filename) shouldnt the variables from the included file work on the file with include in it?
Posted: Mon Jul 08, 2002 1:49 am
by martin
Yes they should. Could the problem be with trying to use variables in functions?
Posted: Mon Jul 08, 2002 10:12 pm
by MattSharp
No. One is a loop control variable and the other are the username and password for logging into a mySQL database.
Posted: Tue Jul 09, 2002 1:39 am
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
Posted: Tue Jul 09, 2002 6:27 pm
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?
Posted: Tue Jul 09, 2002 6:57 pm
by hob_goblin
try
Code: Select all
require_once("http://www.drivingwithflats.com/news/config.php");
Posted: Wed Jul 10, 2002 1:39 am
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