You are here: perl extension for PHP - stuck? « PHP Programming Language « IT news, forums, messages
perl extension for PHP - stuck?

Posted by billb on 05/24/07 14:03

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация