Problems with finding variables from function

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
rich86
Forum Newbie
Posts: 15
Joined: Sun Jun 11, 2006 7:30 pm

Problems with finding variables from function

Post by rich86 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi, i am having problem with trying to get variables into a function that is declared after a require_once...its hard to explain so this is what i have:

Code: Select all

require_once('scripts/vars.php');

watching_messages(some variables){
     find people to send messages too;
     $email = "bla bla {$from vars.php file};
    }

if(user submits add message form)
   add the message to database;
   watching_messages(); //check to see if anyone watching this message
   }
echo "page using variables from vars.php"

hope that gives the general idea, the error i am getting is that in the watching_messages() function the vars arn;t loaded, i have tried suing include and require instead of require_once, but no better. i cannot have a include or anything in the function as there is a function declared in vars.php that cannot be declared twice. its probablt due to my coding but any suggestions??

ps its only happened since there was a server update and security increased for php files running.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

see http://www.php.net/language.variables.scope
therefore
ps its only happened since there was a server update and security increased for php files running.
is unlikely. Maybe the error message was suppressed in past.
rich86
Forum Newbie
Posts: 15
Joined: Sun Jun 11, 2006 7:30 pm

Post by rich86 »

many thanks, it was just me not reading the manual properly.
Post Reply