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
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
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.
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...
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.
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.
jstu...@attglobal.net
==================
thanks again.
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.
You cheat :)
utp_http != htp.p
It's odd you have to do this migration, Oracle supports PHP quite well.
Gerard