Hi there!
I've found the following code on an webpage but it does
not work correctly. Starting the script only shows the ID which is in values[0] and values[1] has no data. I don`t understand that, so I hope you do!
I'm using Apache with PHP4 and OCI support and Oracle 8.0.5 on a Sun Solaris machine.
Here's the interesting part of the code:
PutEnv("ORACLE_SID=ORCL");
$tns = "(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = hostname)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = hostname.cognid.de)))";
$connection = OCILogon ("user","pass",$tns);
if ($connection == false){
echo OCIError($connection)."<BR>";
exit;
}
$query = "select * from anrede";
$cursor = OCIParse ($connection, $query);
if ($cursor == false){
echo OCIError($cursor)."<BR>";
exit;
}
$result = OCIExecute ($cursor);
if ($result == false){
echo OCIError($cursor)."<BR>";
exit;
}
while (OCIFetchInto ($cursor, $values)){
$id = $values[0];
$anrede = $values[1];
echo "ID: $id, Anrede: $anrede";
}
So long,
Michael
I've found the following code on an webpage but it does
not work correctly. Starting the script only shows the ID which is in values[0] and values[1] has no data. I don`t understand that, so I hope you do!
I'm using Apache with PHP4 and OCI support and Oracle 8.0.5 on a Sun Solaris machine.
Here's the interesting part of the code:
PutEnv("ORACLE_SID=ORCL");
$tns = "(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = hostname)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = hostname.cognid.de)))";
$connection = OCILogon ("user","pass",$tns);
if ($connection == false){
echo OCIError($connection)."<BR>";
exit;
}
$query = "select * from anrede";
$cursor = OCIParse ($connection, $query);
if ($cursor == false){
echo OCIError($cursor)."<BR>";
exit;
}
$result = OCIExecute ($cursor);
if ($result == false){
echo OCIError($cursor)."<BR>";
exit;
}
while (OCIFetchInto ($cursor, $values)){
$id = $values[0];
$anrede = $values[1];
echo "ID: $id, Anrede: $anrede";
}
So long,
Michael