I have a script that runs that checks for the existance of another and executes a mail script if it is found. I works just fine except that it does not pass the $utility variables along(see script below). Yet, when I run it independent of the entire script it works fine - all variables pass along. I hope this seems clear. The variable $utilityid is passed from the overall script. If I run it independent it is set at the begining. I know it is getting passed because the query on the second part would fail. Here is the mail part of the script:
$connect=odbc_connect("$dbname","$dbuser","$dbpass");
$query="SELECT UtilityURL, UtilityEmailAddress1, UtilityName from UtilityInfo where UtilityID=$utilityid";
$result=odbc_do($connect,$query);
while (odbc_fetch_into($result,&$field))
{
$utilityurl=$field[0];
$utilityemail=$field[1];
$utilityname=$field[2];
}
$query="SELECT BillingAcountNo, WebPIN, EmailAddress from NewActivations where UtilityID=$utilityid";
$result=odbc_do($connect,$query);
while (odbc_fetch_into($result,&$fields))
{
$accountno=$fields[0];
$pass=$fields[1];
$custemail=$fields[2];
$subject="Your Online Viewing Account Activation from $utilityname";
$mailcontent="
Thank you for activating your account with $utilityname.\n
\n
You can access the online viewing through $utilityurl.\n
\n
Your account number is $accountno\n
Your password is $pass\n
\n
Please keep this and all other passwords in a safe location.
";
$fromaddress="From: $utilityemail";
mail("$custemail", $subject, $mailcontent,"$fromaddress");
}