Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Variables from Include file not coming through

0 views
Skip to first unread message

jl13...@bellsouth.net

unread,
Dec 14, 2009, 8:35:15 AM12/14/09
to
I am a complete PHP newbie - however I have been coding for a living
for a long time, mostly C and C++.

I recently "inherited" support of a php website. It uses ODBC for
database connections (dont ask why). Anyway, I decided to set up a
development server at home. I am having the following problem, for
which I will provide a test code sample - when I instantiate an
ODBC_Connect withing an operating piece of code, it works fine, but
when the same ODBC_Connect statement is issued within an included
file, the value returned is a null, so the ODBC connection fails. Here
is the code:

<?php
$sql="SELECT lastname FROM aruser where webuser='XXXX' and
password='XXXX'";

/////////////////////////////////////////////////////////////////////////////
// if I uncomment the "include" line and comment the direct
// odbc_connect call, it doesnt work
// if I comment the "include" line and uncomment the direct
// OBDC_Coonect call, it DOES work
/////////////////////////////////////////////////////////////////////////////
unset($ASAP);
//include '.\ASAP\includes\global.inc';
$ASAP = odbc_connect('JWOUTODBC','','') or die('Could Not Connect to
ODBC Database!');
///////////////////////////////////////////////////////////////////////////////
// the following statement dsipalys NULL if I use the include
// statement, and "resource(1) of type (odbc link) " if I dont
///////////////////////////////////////////////////////////////////////////////
var_dump($ASAP);
print '<br>';
$rs=odbc_exec($ASAP,$sql);
if (!$rs)
{exit("Error in SQL");}
echo "<table><tr>";
echo "<th>Name</th></tr>";
while (odbc_fetch_row($rs))
{
$lastname=odbc_result($rs,"lastname");
echo "<tr><td>$lastname</td></tr>";
}
odbc_close($ASAP);
echo "</table>";
?>

</body>

The include file is thus:
<?
if (!isset($ASAP)) {
$ASAPWEB = "1.0.0";
//ODBC Connection
$ASAP = odbc_connect('JWOUTODBC','','') or die('Could Not
Connect to ODBC Database!');
//Directory Locations
$GRAPHICS = "C:/apps/asap/asapv/GRAPHICS";
// added by RAK for lookup in SY*.DBF
$ASAPDIR = "C:/apps/asap/asapv";
$DATADIR = "C:/apps/asap/asap-dbf";

$thumbwidth="100";
$colnumb="4";

//Variable Declairs
$link = "";
$direction = "";
$target = "";

//Web Navigation
$HOME = $_ENV['HTTP_HOST'];
$BADLOGIN = $_ENV['HTTP_HOST']."/ASAP/usrlogon.php";

//ICVERIFY POOLER DATA
$ICVDIR = "c:/icvpoolr/";
$ICVMERCHANT = "9999999999";
$EMERGENCYPHONE = "XXX-XXX-XXXX";

}

?>

Can anyone help me please???

TIA

0 new messages