|
Posted by Tyno Gendo on 05/25/07 15:02
billb wrote:
> I installed a perl extension for PHP to use some perl inside my php
> primarily because I have perl working with oracle and not php and
> oracle. So I want to use my old perl scripts, and use the
> functionality of php. The extension uses the '$perl->eval' function.
>
> i am kind of stuck with the syntax or how to put the php variable into
> the perl script. I have a form where the user puts in a grid
> reference. Then a php script that gets the entered values and puts
> them into a sql. Except all that bit is in Perl. How can this be done?
>
> <?php
> //php request
> $easting = $_REQUEST['easting'];
> $northing= $_REQUEST['northing'];
>
> //perl code
> $perl = new Perl();
>
> $perl->eval('use CGI');
> $perl->eval('use DBI');
>
> // declare variables
> $perl->eval('my ($dbh, $sth, $cgi, $the_value, $easting,$northing)');
>
> //instance of the cgi module
> $perl->eval('$cgi=new CGI');
>
> //connects to the database
> $perl->eval('$dbh = DBI-
>> connect("DBI:Oracle:server_name","username","password")');
>
> $perl->eval('$sth= $dbh->prepare("Select value from tblData
> where Easting=?
> and Northing=?")');
>
> // in perl this would take these 2 variables and put them in the '?'
> of the sql bit
> $perl->eval('$sth->bind_param(1, $easting)');
> $perl->eval('$sth->bind_param(2, $northing)');
>
> //execute etc
> $perl->eval('$sth->execute');
>
> // bind the query result to $the_value variable
> $perl->eval('$sth->bind_columns(\$the_value)');
> $perl->eval('($sth->fetch)');
>
> //print result
> $perl->eval('print "$the_value"');
>
> ?>
>
> thanks
>
We have Perl scripts and we call them from PHP just using fopen() and
have Perl send back simple text delimited results, or using CuRL
instead, then just parse the returned text in PHP.
[Back to original message]
|