By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,159 Members | 1,941 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,159 IT Pros & Developers. It's quick & easy.

php code from plsql using owa htp.p

P: n/a
Hi,

can I run phpinfo(); or any php code from an oracle plsql package using

htp.p from the oracle web toolkit owa?

what I need is to run any php code using htp.p()
I might be missing something, in my oracle/apache/php configuration I
can only run flat .php files from /htdocs but can't run any php from a
plsql procedure to display on a browser with htp.p
anyone has ideas?

thanks in advance,
-- pedro.

Feb 28 '06 #1
Share this Question
Share on Google+
15 Replies


P: n/a

<ma*****@hotmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
: Hi,
:
: can I run phpinfo(); or any php code from an oracle plsql package using
:
: htp.p from the oracle web toolkit owa?
:
: what I need is to run any php code using htp.p()
: I might be missing something, in my oracle/apache/php configuration I
: can only run flat .php files from /htdocs but can't run any php from a
: plsql procedure to display on a browser with htp.p
:
:
: anyone has ideas?
:
: thanks in advance,
: -- pedro.
:

i'll take a stab at it...

php is server-side processing, and, in essence, so is mod_plsql (htp.p, et
al)

so the output from htp.p is not being furhter processed on the server, it is
being streamed back to the user -- the same as if you generated PHP code
from a PHP page ... it would go back to the user not to the server-side
processor

++ mcs
Feb 28 '06 #2

P: n/a
Mark C. Stock schrieb:
<ma*****@hotmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
: Hi,
:
: can I run phpinfo(); or any php code from an oracle plsql package using
:
: htp.p from the oracle web toolkit owa?
:
: what I need is to run any php code using htp.p()
: I might be missing something, in my oracle/apache/php configuration I
: can only run flat .php files from /htdocs but can't run any php from a
: plsql procedure to display on a browser with htp.p
:
:
: anyone has ideas?
:
: thanks in advance,
: -- pedro.
:

i'll take a stab at it...

php is server-side processing, and, in essence, so is mod_plsql (htp.p, et
al)

so the output from htp.p is not being furhter processed on the server, it is
being streamed back to the user -- the same as if you generated PHP code
from a PHP page ... it would go back to the user not to the server-side
processor

++ mcs


Not being familiar with php, but the output of mod_plsql can be
redirected via mod_external to php processor, so theoretically , if
security restrictions could be disregarded, it should be possible...

Best regards

Maxim
Feb 28 '06 #3

P: n/a
how exactly would I do that Max?

Mar 1 '06 #4

P: n/a
ma*****@hotmail.com schrieb:
how exactly would I do that Max?


I was most likely wrong with my suggestion,
the idea was to run additional Apache (as proxy, because OHS comes
without mod_ext_filter.so ) with mod_ext_filter and output filter
defined as "/usr/local/bin/php" . I made some tests with another simple
filter, such as sed - it seems to work with mod_plsql together, but in
case of php - i got "No input file specified", which i don't know how to
overcome.

Best regards

Maxim
Mar 1 '06 #5

P: n/a
Hi Pedro,

two other common approaches to incorporating output from technologies
are:

(1) using an IFRAME to call your PHP code using a different http
request
(2) using UTL_HTTP to call your PHP code from the backend and display
the result using htp.p

~Dietmar.

Mar 2 '06 #6

P: n/a
Hi Dietmar,

thanks for the tip, but I'm using exactly UTL_HTTP for that with htp.p
and it doesn't seem to be showing back the php result.
This is what I have in a plsql package:

begin
htp.p('phpinfo();');
end;

it gives me a blank page when I call the package from the browser. What
I expect is to see the environment variables for PHP with the
phpinfo(); function call.

my setup:
- oracle 9i
- Oracle's HTTP Server with Apache 1.3
- php 5

anything I'm missing?
thanks.

Mar 2 '06 #7

P: n/a
ma*****@hotmail.com wrote:
Hi Dietmar,

thanks for the tip, but I'm using exactly UTL_HTTP for that with htp.p
and it doesn't seem to be showing back the php result.
This is what I have in a plsql package:

begin
htp.p('phpinfo();');
end;

it gives me a blank page when I call the package from the browser. What
I expect is to see the environment variables for PHP with the
phpinfo(); function call.

my setup:
- oracle 9i
- Oracle's HTTP Server with Apache 1.3
- php 5

anything I'm missing?
thanks.


1) Your browser requests http://yourserver/plsql_dad/your_procedure
2) Apache by Oracle recognizes the plsql_dad bit, and hands the request
off to mod_plsql.
3) mod_plsql has some login processing, define in the Database
Access Descriptor (dad), but will eventually call your procedure.
4) Your procedure sends the string phpinfo(); back to mod_plsql, that
faithfully hands it off to Apache, that will send it back to your
browser.
5) Your browser does not understand phpinfo(); and displays a blank
page. Hint: check page source

What did *I* forget here? Do you understand the sequence of
events above? If you do, you should be able to understand why
you do not get what you expected.

Now, as we already established, I know nothing about php, but it
seems to me, that:
1) Your browser needs to send phpinfo(); (not *receive* it)
2) And it needs to be sent to the php environment, not the
Oracle pl/sql stack.

So, we're back at what was suggested before: link those two.
--
Regards,
Frank van Bortel

Top-posting is one way to shut me up...
Mar 2 '06 #8

P: n/a
Yep, something missing ;).

The following sample should get you started, I just picked a random
php-url from the web:

create or replace procedure test_utl_http is
req utl_http.req;
resp utl_http.resp;
value VARCHAR2(1024);
BEGIN
--utl_http.set_proxy('proxy.my-company.com', 'corp.my-company.com');

req :=
utl_http.begin_request('http://www.yessoftware.com/products/product_detail.php?product_id=1');
--utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
resp := utl_http.get_response(req);
LOOP
utl_http.read_line(resp, value, TRUE);
htp.p(value);
END LOOP;
utl_http.end_response(resp);
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
END;
/
grant execute on test_utl_http to public
/
Do some research on UTL_HTTP and how to use it. There are plenty of
samples out there.

~Dietmar.

Mar 2 '06 #9

P: n/a
Frank van Bortel wrote:
ma*****@hotmail.com wrote:
Hi Dietmar,

thanks for the tip, but I'm using exactly UTL_HTTP for that with htp.p
and it doesn't seem to be showing back the php result.
This is what I have in a plsql package:

begin
htp.p('phpinfo();');
end;

it gives me a blank page when I call the package from the browser. What
I expect is to see the environment variables for PHP with the
phpinfo(); function call.

my setup:
- oracle 9i
- Oracle's HTTP Server with Apache 1.3
- php 5

anything I'm missing?
thanks.
1) Your browser requests http://yourserver/plsql_dad/your_procedure
2) Apache by Oracle recognizes the plsql_dad bit, and hands the request
off to mod_plsql.
3) mod_plsql has some login processing, define in the Database
Access Descriptor (dad), but will eventually call your procedure.
4) Your procedure sends the string phpinfo(); back to mod_plsql, that
faithfully hands it off to Apache, that will send it back to your
browser.
5) Your browser does not understand phpinfo(); and displays a blank
page. Hint: check page source

What did *I* forget here? Do you understand the sequence of
events above? If you do, you should be able to understand why
you do not get what you expected.

Now, as we already established, I know nothing about php, but it
seems to me, that:
1) Your browser needs to send phpinfo(); (not *receive* it)


PHP is a server-side language. The browser never sees the PHP code, and
cannot "send" phpinfo().
2) And it needs to be sent to the php environment, not the
Oracle pl/sql stack.

Yes. I'm not sure how to do it (I don't know mod_plsql) - but the code
needs to be processed throught the PHP parser as well as mod_plsql.
So, we're back at what was suggested before: link those two.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 2 '06 #10

P: n/a
well, that does the job presenting a php page, but the approach I'd
like to have is to code php right on the package and just have the
htp.p spitting out php, without the need to retrieve an existing php
flat file.

thanks again.

Mar 3 '06 #11

P: n/a
Well, how should this be possible?

This would mean that htp.p would have a PHP processor embedded, right?
This is not how web applications work.

Have you ever seen a Java servlet where you can just embed Perl syntax,
PHP or whatever other *server side* language?

You can only achieve this through another http request which is served
by a webserver/appserver running the request through the appropriate
engine to execute it.

~Dietmar.

Mar 3 '06 #12

P: n/a
daust_de wrote:
Yep, something missing ;).


You cheat :)
utp_http != htp.p

--
Regards,
Frank van Bortel

Top-posting is one way to shut me up...
Mar 3 '06 #13

P: n/a
ma*****@hotmail.com wrote:
Hi,

can I run phpinfo(); or any php code from an oracle plsql package using

htp.p from the oracle web toolkit owa?

what I need is to run any php code using htp.p()
I might be missing something, in my oracle/apache/php configuration I
can only run flat .php files from /htdocs but can't run any php from a
plsql procedure to display on a browser with htp.p
anyone has ideas?

thanks in advance,
-- pedro.

Would you mind telling us why you'd want to do that, Pedro?
Mar 3 '06 #14

P: n/a
it's a project from work, I have to migrate some of our php code to
plsql packages and centralize in plsql packages

Mar 4 '06 #15

P: n/a
ma*****@hotmail.com wrote:
it's a project from work, I have to migrate some of our php code to
plsql packages and centralize in plsql packages

I'd advise a rewrite in PL/SQL in that case. If PL/SQL is an
unsurmountable problem, you could have Java packages, but I'd still
advise PL/SQL. Did the project-leader think that Oracle had an imbedded
PHP-engine? Maybe that would be feasible with PostgreSQL, but I'm not
sure.

It's odd you have to do this migration, Oracle supports PHP quite well.

Gerard
Mar 4 '06 #16

This discussion thread is closed

Replies have been disabled for this discussion.