Hi,
I'm a newbie in AS400 database and odbc connection. I'm facing an issue that I have created a database in the AS400 and able to view the database by DOS. But, when I try to use a odbc connection to get the data via PHP, I get nothing from there. It's seems like that I need to do a HTTP cofiguration. Any Suggestions?
These are the codes....
test.php:
<html>
<?php
include("AS400database.php");
global $database;
$id_sql = "SELECT * FROM ".CTLLIB.".SYSEMP";
$result = $database->query($id_sql);
echo "helo";
while(odbc_fetch_array($result))
{
$id = odbc_result($result, 1);
echo $id;
}
?>
</html>
AS400database.php:
<?php
/**
* Database.php
*
* The Database class is meant to simplify the task of accessing
* information from the website's database.
*
* Written by: Lim Swee Ann
* Last Updated: 08/04/2009
*/
include("AS400constants.php");
class MyDB2
{
var $connection; //The Db2 database connection
/* Class constructor */
function MyDB2(){
/* Make connection to database */
$this->connection = odbc_connect(DB_NAME, DB_USER, DB_PASS);
}
/**
* query - Performs the given query on the database and
* returns the result, which may be false, true or a
* resource identifier.
*/
function query($query){
return odbc_exec($this->connection,$query);
if (odbc_error())
{
echo odbc_errormsg($conn);
}
}
};
/* Create database connection */
$database = new MyDB2;
?>
AS400Constants.php:
<?php
/**
* Constants.php
*
* This file is intended to group all constants
*
* Written by: Lim Swee Ann
* Last Updated: 08/04/2009
*/
/**
* Database Constants - these constants are required
* in order for there to be a successful connection
* to the DB2 database. Make sure the information is
* correct.
*/
define("DB_SERVER", "localhost");
define("DB_USER", "YWSDEV");
define("DB_PASS", "YWSDEV");
define("DB_NAME", "AS400");
//odbc_connect(DB_NAME, DB_USER, DB_PASS)
/**
* Special Names and Level Constants
*/
define("GST_RATE", 1.07);
define("GUEST_NAME", "Guest");
define("GST_YES","Y");
define("GST_NO","N");
define("YMS_BRANCHES","1");
define("YMS_LICENSES","2");
define("TABLE_STYLE_1","WIDTH:500px;HEIGHT:52px");
/**/
/** to set current libraries **/
/**/
define("CTLLIB", "BIDEVCTL");
define("LIBLIB", "BIDEVLIB");
//BIYMALIB ==> BIDEVLIB
//YMA/NEW ==> DEV
?>
Thanks for help....