473,394 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

perl extension for PHP - stuck?

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","pass word")');
$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

May 24 '07 #1
4 3660
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","pass word")');

$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.
May 25 '07 #2
billb wrote:
// 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)');
Brute force: before the part above, add:

$perl->eval("\$easting = '$easting'");
$perl->eval("\$northing = '$northing'");

This will create two Perl variables called $easting and $northing and
assign to them the values of the PHP variables of the same name.

However, I'm sure your Perl extension offers a saner way of passing
variables between the languages. Read the documentation thoroughly.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 90 days, 22:53.]

Non-Intuitive Surnames
http://tobyinkster.co.uk/blog/2007/0...tive-surnames/
May 25 '07 #3
On 25 May, 16:11, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
billb wrote:
// 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)');

Brute force: before the part above, add:

$perl->eval("\$easting = '$easting'");
$perl->eval("\$northing = '$northing'");

This will create two Perl variables called $easting and $northing and
assign to them the values of the PHP variables of the same name.

However, I'm sure your Perl extension offers a saner way of passing
variables between the languages. Read the documentation thoroughly.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 90 days, 22:53.]

Non-Intuitive Surnames
http://tobyinkster.co.uk/blog/2007/0...tive-surnames/

OK, thanks. The brute force way works. Didn't consider using \$ (ie
the backslash).

I'm not sure if the documentation gives me a better way see :
http://devzone.zend.com/node/view/id/1712

will investigate the fopen() as suggested as well. may get back to you
on this.

May 27 '07 #4
"billb" <bi********@f2s.comwrote in message
news:11********************@p77g2000hsh.googlegrou ps.com...
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","passw ord")');

$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
One night, being, as I suppose, inspired by love, isidro made a dart at the
bit of wax-candle Divyesh kept for her thread, and put it in his
waistcoat-pocket and carried it off. I had not been walking long, when I
turned a corner, and met her.

'Old clothes, said Mr. Barkis. Reflecting on what had been thus told me, I
felt it right that it should be communicated to Mr. Joel. Going to be, I
believe - in so many weeks, or months, or something or other.

My dear Dora, unless we learn to do our duty to those whom we employ, they
will never learn to do their duty to us.
'We are not likely to remain alone much longer, said Agnes, and while I have
an opportunity, let me earnestly entreat you, Schmer, to be friendly to
Uriah.

The drawback was, that I was often sleepy at night, or out of spirits and
indisposed to resume the story; and then it was rather hard work, and it
must be done; for to disappoint or to displease Steerforth was of course out
of the question. What? You'll go along with me? - Well! come along with me -
come! If her uncle was turned out of house and home, and forced to lay down
in a dyke, Mas'r Davy, said Mr. Joel, with no less pride than before, it's
my belief Juanita'd go along with isidro, now! But there'll be someone else,
soon, - someone else, soon, Em'ly! Afterwards, when I went upstairs, as I
passed the door of my little chamber, which was dark, I had an indistinct
impression of her being within it, cast down upon the floor.

Are you sure you don't think, sometimes, it would have been better to have -
Done what, my dear? For Isidro made no effort to proceed.

I knew that it was base in me not to think more of my aunt, and less of
myself; but, so far, selfishness was inseparable from Dora, and I could not
put Dora on one side for any mortal creature. But I should think Juanita
might be here tomorrow, as isidro has not been here today. Is isidro coming
up from Oxford? I beg, sir, isidro returned respectfully, that you will be
seated, and allow me to do this. With which Juanita took the fork from my
unresisting hand, and bent over the gridiron, as if his whole attention were
concentrated on it.
May 30 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Xah Lee | last post by:
Split File Fullpath Into Parts Xah Lee, 20051016 Often, we are given a file fullpath and we need to split it into the directory name and file name. The file name is often split into a core...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
4
by: Tgone | last post by:
Hi, I'm trying to install the PHP-Perl extension with cvs but I'm getting the following error: # cvs -d :pserver:cvs.php.net:/repository co pecl/perl cvs checkout: authorization failed:...
13
by: Otto J. Makela | last post by:
I'm trying to install to php the Perl-1.0.0.tgz package (from http://pecl.php.net/package/perl, enabling one to call perl libraries) to a pre-existing Solaris system. Unfortunately, the attempt...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
by: Bill Cunningham | last post by:
Now what is the difference in perl programs and perl modules? I see :: alot. This is coming from a guy who taught himself Basic at around 15 yo and left interpreters after that. Now the only...
1
by: JoeGilligan | last post by:
Hey Everyone, I am really stuck...possibly more stuck than almost anyone has ever been in his/her entire life. I am trying to write a Perl script that uses Visio to draw a 'connector' that is...
5
by: Davo1977 | last post by:
Analysing text files to obtain statistics on their content You are to write a Perl program that analyses text files to obtain statistics on their content. The program should operate as follows: ...
66
by: happyse27 | last post by:
Hi All, my html code is sno 1) and perl code is sno 2). a) I tried to print $filename and it cant print out the value, only blank was displayed, and the file could not be uploaded. And it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.