Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Does Oracle HTTP Server can support PHP5 ?

151856Nov 23 2008 — edited Feb 12 2009
I just downlaod a Oracle HTTP Server from OTN , after installion , It show can support PHP4 ,but I want to know does it can support PHP5 too? How can do ? TKS

Comments

244142
I use
Firefox Browser 3.0.4
Oracle 11g1
Fedora 9
oci8
php 5.2.6
Apache 2

the php programs under the apache server does database operations

I have yet to try the Oracle server:

did you download 11g1 Oracle server

do you have the link or startup instructions?

I may have the Oracle server in my 11g1
164043
You mean APEX? Well yes, it can, but that is a rather troublesome exercise, specific to the OS. On Linux, you would need to link PHP5 module manually. It is also rather pointless as PL/SQL and PHP cannot communicate. There is no way to see and address the objects in APEX from PHP. It would be handy, I admit, but it just isn't possible. The main use for that would be to interface with the OS.
244142
thanks but I have no idea what apex is!
Michael McLaughlin
Do you mean the Oracle HTTP Server that shipped with Oracle 10g? It's on the companion CD for that release. Another alternative is the Oracle Application Server, but rumor has it that's problematic.

Oracle changed it when they released Oracle 11g, they renamed it as the XML DB. Oracle 10g Express Edition shipped with the XML DB installed and configured to run APEX (Application Express - more or less the old HTMLDB development platform). I don't know if you can configure it to run PHP 5.x but you probably can do it.

Unknowns but thoughts:

1. You'll need to configure access to libraries by using the ENV property in the SID_LIST_CALLOUT_LISTENER in your listener.ora file. It lets you have access to external libraries. XML DB (an Oracle HTTP Server is built in the database) will need to callout to the library because I've not seen a way to include the library (but there may be a way to do it).
2. You use the DMBS_EPG package to set parameters in the equivalent of the httpd.conf file (you create that with the @?/rdbms/admin/epgstat.sql script).
3. You can probably put the PHP files into CLOB columns and wrap reading of those by using a PL/SQL package.
4. I don't think it's supported.

Hope this helps ...
244142
my php works!

I installed 11g1 enterprise! PHP 5.2.6

Thanks for the info...I'll look at it today!

Code needs some cleaning

<?php
/*
drop sequence logid;
create sequence logid
increment by 1
start with 1;

drop table log_book_id;

create table log_book_id ( log_id number primary key, fdate date, actype varchar2(16), acid varchar(16), nlandings number, nhoursnumber);

insert into log_book_id values (logid.nextval, TO_DATE('08/12/1973','MM/dd/YYYY'),'C150','N5787G',1,1.8);

insert into log_book_id values (logid.nextval, TO_DATE('08/17/1973','MM/dd/YYYY'),'C150','N5787G',3,1.5);

insert into log_book_id values (logid.nextval, TO_DATE('08/26/1973','MM/dd/YYYY'),'C150','N5787G',10,1.8);

insert into log_book_id values (logid.nextval, TO_DATE('09/01/1973','MM/dd/YYYY'),'C150','N5293S',9,1.7);
*/
$db = "(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = LMKIIIGDNSID)
)
)";
if ($conn=oci_connect('landon', 'password',$db))
{
echo "Successfully connected to Oracle.\n";
}
else
{
$err = OCIError();
echo "Oracle Connect Error " . $err['message'];
}

//construct a global variable for the form profile
$fields = array("fdate", "actype", "acid", "nlandings", "nhours");
///

// If the submit button has been pressed
if (isset($_POST['select'])){
displayDeleteForm();
}elseif(isset($_POST['delete'])){
deleteRecords();
} elseif(isset($_POST['insert'])){
insertRecord();
} elseif (isset($_POST['new'])){
displayEntryForm();
} else {
//default action
displayEntryForm();
}

//...........................................................................function displayDeleteForm()

function displayDeleteForm(){
//get $fields into the function namespace
global $fields;
global $conn;
/* Create and execute query. */
// Loop through each row, outputting the actype and name
echo <<<HTML
Pilots Logbook entries stored in Oracle Relational Database
under Redhat Fedora 8 Linux
<form action="{$_SERVER['PHP_SELF']}" method="post">
<table width="50%" align="center" border="1">
<tr>
<th>checked</th>
<th>rowID</th>
<th>fdate</th>
<th>actype</th>
<th>acid</th>
<th>nlandings</th>
<th>nhours</th>
</tr>
HTML;

//get log_book_id table information
$user = "select * from log_book_id";
$result = oci_parse($conn, $user);
$r = oci_execute($result);

//display log_book_id information

$count = 0;
while ($newArray = oci_fetch_assoc($result)) {
if ($count == 0) print_r($newArray);
$count = 1;
foreach ($fields as $field){
$fieldx = strtoupper($field);
${$field} = $newArray[$fieldx];
$count = $count +1;
// print($field);
// print_r($newArray[$field]);
}
$rowID = $newArray['LOG_ID'];

//note that we do not rely on the checkbox value as not all browsers submit it
//instead we rely on the name of the checkbox.
echo <<<HTML
<TR>
<td>
<input type="checkbox" name="checkbox[$rowID]" value="$rowID">Check to delete record
</td>
<TD>$rowID</TD>
<TD>$fdate</TD>
<TD>$actype</TD>
<TD>$acid</TD>
<TD>$nlandings</TD>
<TD>$nhours</TD>
</TR>

HTML;

} // while
echo <<<HTML
<tr>
<td colspan="7">
<input type="submit" name="delete" value="delete checked items"/>&nbsp;
<input type="submit" name="new" value="New Log Entry" />&nbsp;
<input type="reset" name="reset" value="Reset Form" />
</td>
</tr>
</table>
</form>

HTML;
} //close function


// ................................................................. function deleteRecords()
//

function deleteRecords(){

$db = "(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))

(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = LMKIIIGDNSID)
)
)";

// Loop through each log_book_id with an enabled checkbox
if (!isset($_POST['checkbox'])){
return true;
}
//else

foreach($_POST['checkbox'] as $key=>$val){
$toDelete[] = $key;
}
//expand the array for an IN query
$where = implode(',', $toDelete);

if ($conn=oci_connect('landon', 'PW',$db))
{
echo "Successfully connected to Oracle D.\n";
}
else
{
$err = OCIError();
echo "Oracle Connect Error " . $err['message'];
}

$query = "DELETE FROM log_book_id WHERE log_id IN ($where)";
echo($query);
$result = oci_parse($conn, $query);
$r = oci_execute($result);
// Commit transaction
$committed = oci_commit($conn);
// Test whether commit was successful. If error occurred, return error message
if (!$committed) {
$error = oci_error($conn);
echo 'Commit failed. Oracle reports: ' . $error['message'];
}
// Should have one affected row
if ((oci_num_rows($result)== 0) ) {
echo "<p>There was a problem deleting some of the selected items.</p><p>".oci_error().'</p>';
// exit();
} else {
echo "<p>The selected items were successfully deleted.</p>";
}
//direct the user back to the delete form
displayDeleteForm();
} //end function

//...........................................................................function insertRecord()

function insertRecord(){
$db = "(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = LMKIIIGDNSID)
)
)";
if ($conn=oci_connect('landon', 'PW',$db))
{
echo "Successfully connected to Oracle.\n";
}
else
{
$err = OCIError();
echo "Oracle Connect Error " . $err['message'];
}
// Retrieve the posted log book information.
global $fields;
//add some very crude validation
foreach ($fields as $field){
if (empty($_POST[$field])){
$messages[] = "You must complete the field $field \r\n";
} else {
$dFields[$field] = mysql_real_escape_string(trim($_POST[$field]));
}
}
if (count($messages)>0) {
displayEntryForm($messages, $dFields);
exit();
}
//end validation

//get variables into the namespace
extract($dFields);
// Insert the log book information into the log book table
// $query = "INSERT INTO log_book_id SET fdate='$fdate', actype='$actype',
//acid='$acid', nlandings='$nlandings', nhours = '$nhours'";
$query = "INSERT INTO log_book_id (log_id , fdate, actype, acid, nlandings, nhours) values (logid.nextval,'$fdate','$actype','$acid','$nlandings','$nhours')";

echo ($query);
$result = oci_parse($conn, $query);
$r = oci_execute($result);
// Display an appropriate message
if ($r) {
echo "<p>Product successfully inserted!</p>";
}else {
echo "<p>There was a problem inserting the log book!</p>";
$error = oci_error($conn);
echo 'Insert failed. Oracle reports: ' . $error['message'];

}
//direct the user back to the entry form

// Commit transaction
$committed = oci_commit($conn);
// Test whether commit was successful. If error occurred, return error message
if (!$committed) {
$error = oci_error($conn);
echo 'Commit failed. Oracle reports: ' . $error['message'];
}
// Should have one affected row
if ((oci_num_rows($result)== 0) ) {
echo "<p>There was a problem inserting some of the selected items.</p><p>".oci_error().'</p>';
// exit();
} else {
echo "<p>The selected items were successfully inserted.</p>";
}
displayEntryForm();
}

//...........................................................................function displayEntryForm()
function displayEntryForm($errorMessages=null, $dFields=null){
if (!empty($errorMessages)){
echo "<ul><li>".explode('</li><li>', $errorMessages) . "</li></ul>";
}

//sort out field values
global $fields;
foreach ($fields as $field){
if (isset($dFields[$field])){
${$field} = $dFields[$field];
} else {
${$field} = '';
}
}

echo <<<HTML
<form action="{$_SERVER['PHP_SELF']}" method="post">
<p>
Flight Date:
<input type="text" size="20" maxlength="40" name="fdate"
value="$fdate" />
</p>
<p>
Aircraft Type:
<input type="text" size="20" maxlength="40" name="actype"
value="$actype" />
</p>
<p>
Aircraft ID:
<input type="text" size="20" maxlength="40" name="acid"
value="$acid" />
</p>
<p>
Number Landings:
<input type="text" size="20" maxlength="40" name="nlandings"
value="$nlandings" />
</p>
<p>
Number Hours:
<input type="text" size="20" maxlength="40" name="nhours"
value="$nhours" />
</p>
<button type="submit" name = "insert" value="Insert Row!"
style="color:maroon font:18pt Courier; font-weight:bold ">Insert Row
</button>
<button type="submit" name = "select" value="Show All!"
style="color:red font:18pt Courier; font-weight:bold ">Show All
</button>
<button type="submit" name = "delete" value="Delete Row!"
style="color:red font:18pt Courier; font-weight:bold ">Delete Row!
</button>
</form>
HTML;
} //end display function
?>
244142
I signed up for Apex and found that the sql files that ran well under 11g1 (Windows and Fedora 9)

DO NOT run under apex! A person on this forum told me that apex would only accept 1 sql statement at a time!

I have a long sql script that I use to evaluate RDBs.

This script makes it easy to load a table since sql is usually universal!

Yes I could use a loader but the formatting would be a beast!

I forgot where it was but I encountered an Oracle facility where the ";"s had to be removed.
WHEW!

Does OAS=APEX? isomorphically?

Accessing a 11g1 table is simple with PHP...

I have a browser/php program that works on XP Prof SP3 IIS5,1 or Fedora 9 Apache 2.2

XML is prob the universal "language" I need.
244142
PHP 5.2.6 through

XP Prof IIS 5.1

OR

Fedora 9 Apache 2.2

handles stored procedures PL/SQL
DO NOT run under apex! A person on this forum told me that apex would only accept 1 sql statement at a time!
You are misinformed: Oracle Apex has the ability to run scripts. After logging in, navigate to SQL Workshop -> SQL Scripts. See page 37 of the current (1.5) version of http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf for screen shots.
244142
great news...thanks...I'll pass along your info to the ace on this forum who

told me that

He works for the mob in Chicago!
1 - 9
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 12 2009
Added on Nov 23 2008
9 comments
4,038 views