I am running the follwing script :
<?php
// include our custom function libraries
include_once("db2lib.php");
//include_once("db2form.php");
?>
<?php
// select all rows from the AUTHOR table
//$select_stmt = "SELECT last_name, first_name, middle_initial, author_id " .
$select_stmt = "SELECT * FROM OCM.SPEC_HANDLING_REQ ORDER BY req_date_rms DESC, req_time_rms DESC";
printf("%s",$select_stmt);
if ($dbconn != 0) {
// odbc_exec returns 0 if the statement fails;
// otherwise it returns a result set ID
$result = odbc_exec($dbconn, $select_stmt);
if ($result == 0) {
echo("SELECT statement failed.");
$sqlerror = odbc_errormsg($dbconn);
echo($sqlerror);
}
else {
// odbc_result_all prints all of the rows
// for a result set ID as an HTML table
odbc_result_all($result);
}
}
?>
and when i run it, i get the follwing error message:
Notice: Undefined variable: dbconn in /srv/www/htdocs/ORS/db2select.php on line 19
However this variable is defined in the include_once statement above in the file db2lib.php . Here is the code below:
<?php function dbconnect($verbose) {
$dbname = "****";
$username = "*";
$password = "****";
// odbc_connect returns 0 if the connection attempt fails;
// otherwise it returns a connection ID used by other ODBC functions
$dbconn = odbc_connect($dbname, $username, $password);
if (($verbose == TRUE) && ($dbconn == 0)) {
echo("Connection to database failed.");
$sqlerror = odbc_errormsg($dbconn);
echo($sqlerror);
}
return($dbconn);
}
?>
What could be the reason why $dbconn is not defined as a variable? is there something that i am missing in my php.ini?
TIA,
Cameron