trouble with variables in an include file

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
phpBever
Forum Commoner
Posts: 42
Joined: Fri Aug 07, 2009 10:23 am

trouble with variables in an include file

Post by phpBever »

I keep having trouble with Apache/PHP recognizing variables in my include() file.

Thus I have a program that has this structure:

Code: Select all

<?php
$campaignNo = '22222';
include('aFile');
?>
And aFile looks like this pattern:

Code: Select all

<?php
  //for example
  echo $campaignNo;
?>
These seem to work fine for me. But the parallel setup--as nearly as I can see--in my program gives the "undefined variable" error message in the Apache log:
[Mon Jun 28 17:39:05 2010] [error] [client ...] PHP Notice: Undefined variable: campaignNo in ...misc_DirMsg.php on line 38
The supposedly guilty lines are
$Signer_fileName = "signup_csv/".$campaignNo.".csv";
$Target_fileName = "target_csv/".$campaignNo.".csv";
I don't get an error when I put these lines into aFile, as nearly as I can tell.

What kinds of things might be causing this problem? I've already moved my include() below where I extract the variables from $_POST--so I'm sure the variables are declared and have value before the include() file would use them--but that doesn't seem to have helped.
Post Reply