|
-
Aug 15th, 2003, 03:34 PM
#1
Thread Starter
Stuck in the 80s
[Resolved] ***? Global problem...
I'm doing this sort of thing in numerous scripts, however, in ONE FILE, it's not working.
Here's a condensed version of the code:
Code:
<?php
$CONFIG['absolute_path'] = '/home/vbshelf/public_html/reality/news/';
//config.php simply loads some variables from a database
//into the $CONFIG array:
include $CONFIG['absolute_path'] . 'config.php';
echo $CONFIG['numitems'] . '<br>'; //WORKS!
function _news($cat = '') {
global $CONFIG;
echo $CONFIG['numitems'] . '<br>'; //DOESN'T WORK?
}
?>
What gives?!
Last edited by The Hobo; Aug 17th, 2003 at 09:44 PM.
-
Aug 17th, 2003, 03:45 PM
#2
Thread Starter
Stuck in the 80s
This doesn't make any sense whatsoever...
Anybody...?
-
Aug 17th, 2003, 09:43 PM
#3
Thread Starter
Stuck in the 80s
I fixed it. I don't know how...but it works.
-
Aug 18th, 2003, 10:59 AM
#4
Frenzied Member
the only thing I can see if it doesn't work is if you didn't run that function. but seeing how it is resolved then cool
-
Aug 18th, 2003, 12:29 PM
#5
Thread Starter
Stuck in the 80s
Originally posted by phpman
the only thing I can see if it doesn't work is if you didn't run that function. but seeing how it is resolved then cool
I was running the function. Matt and I spent like an hour trying to figure it out, and then I changed one small thing (in a file we weren't even looking at) and it worked. Still didn't make sense, but...oh well.
-
Aug 27th, 2003, 11:16 PM
#6
Member
I had this problem a little while ago. I had a function that included the file which had my variable in it. So at the top of my file with the variable, I added "gloabl $myvar" and when the function went to include the file everything was fine. I had something like this:
PHP Code:
function incFunc()
{
$files = array("file1.php", "file2.php");
foreach($files as $file)
{
include($file);
}
}
// file1.php, example
global $config;
$config = array("var" => "variable", "welcome" => "bonjour");
-
Sep 1st, 2003, 01:42 PM
#7
Thread Starter
Stuck in the 80s
Pretty much sounds like what I had to do to fix it.
Crazy thing was that it worked fine on my PC, but didn't work on my host's server.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|