|
Posted by LeaFriend on 02/14/06 05:26
Hello.
It's rainy day of winter in here. :(
I install php on AIX, with OCI8 ext.
WebServer is WebtoB, WAS is JEUS.
There was a problem on compiling (oci.h is not found) and linking.
(machine was 32bit system, but default oracle library path
/tmax/oracle/client/lib is for 64bit)
Anyway, i fixed Makefile and php work well with OCI on CLI.
This is my script.
#!/usr/local/bin/php -f
<?php
$conn = ociLogon('scott', 'tiger', 'testdb');
$stmt = ociParse($conn, "SELECT COUNT(*), MAX(entry_date) FROM
ct_abbr");
ociExecute($stmt);
if (ociFetch($stmt)) {
echo "COUNT(*) : ", ociResult($stmt, 1), "\n";
echo "MAX(entry_date) : ", ociResult($stmt, 2), "\n";
ociFreeStatement($stmt);
}
ociLogoff($conn);
?>
When I run ./oci.php, It shows good result.
COUNT(*) : 9364
MAX(entry_date) : 20060213
But I try to access it via web, it doesn't work.
First i found environmental variables aren't set.
so modified source to add puenv()
<?php
ini_set("display_errors", 1);
$ORACLE_BASE = "/tmax/oracle";
$ORACLE_HOME = "$ORACLE_BASE/client";
$PATH = getenv("PATH") . ":$ORACLE_HOME/bin";
$LD_LIBRARY_PATH = "$ORACLE_HOME/lib";
$TNS_ADMIN = "$ORACLE_HOME/network/admin";
$NLS_LANG = "American_america.KO16KSC5601";
putenv("ORACLE_BASE=$ORACLE_BASE");
putenv("ORACLE_HOME=$ORACLE_HOME");
putenv("PATH=$PATH");
putenv("LD_LIBRARY_PATH=$LD_LIBRARY_PATH");
putenv("TNS_ADMIN=$TNS_ADMIN");
putenv("NLS_LANG=$NLS_LANG");
$que = "SELECT COUNT(*), MAX(entry_date) FROM ct_abbr";
$conn = ociLogon('scott', 'tiger', 'testdb'); //exit($stmt);
$stmt = ociParse($conn, $que); //exit($stmt);
ociExecute($stmt);exit($stmt);
if (ociFetch($stmt)) {
echo "COUNT(*) : ", ociResult($stmt, 1), "\n";
echo "MAX(entry_date) : ", ociResult($stmt, 2), "\n";
ociFreeStatement($stmt);
}
ociLogoff($conn);
?>
This script work until ociParse().
But if ociExecute() is called, browser show white page.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type
content="text/html; charset=ks_c_5601-1987"></HEAD>
<BODY></BODY></HTML>
I don't know why it work on cli, but not on cgi.
(phpinfo() show Server API is cgi)
Please help me...
Navigation:
[Reply to this message]
|