473,699 Members | 3,103 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,$north ing)');

//instance of the cgi module
$perl->eval('$cgi=n ew CGI');

//connects to the database
$perl->eval('$dbh = DBI-
>connect("DBI:O racle:server_na me","username", "password") ');
$perl->eval('$sth= $dbh->prepare("Selec t 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 3704
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,$north ing)');

//instance of the cgi module
$perl->eval('$cgi=n ew CGI');

//connects to the database
$perl->eval('$dbh = DBI-
>connect("DBI:O racle:server_na me","username", "password") ');

$perl->eval('$sth= $dbh->prepare("Selec t 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("\$eastin g = '$easting'");
$perl->eval("\$northi ng = '$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...@t obyinkster.co.u k>
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("\$eastin g = '$easting'");
$perl->eval("\$northi ng = '$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******** ************@p7 7g2000hsh.googl egroups.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,$north ing)');

//instance of the cgi module
$perl->eval('$cgi=n ew CGI');

//connects to the database
$perl->eval('$dbh = DBI-
connect("DBI:Or acle:server_nam e","username"," password")');

$perl->eval('$sth= $dbh->prepare("Selec t 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
12375
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 part and a extension part. For example: '/Users/t/web/perl-python/I_Love_You.html' becomes
0
9741
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. I need it to be compiled with threads. Anyone have any wisdom on how best to do this? Here's a transcript of my latest attempt. It's long; you might want to skip to the bottom, where I try "make" and the fatal errors start happening.
4
2740
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: server cvs.php.net rejected access to /repository for user root cvs checkout: used empty password; try "cvs login" with a real password
13
3258
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 fails in a rather dramatic way, spewing out thousands of "relocation remains"... I'm somewhat lost on what to do next, the documentation that came along with the Perl package is somewhat sparse. Anyone have suggestions? % uname -a
21
34414
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 obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
1
2967
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 translators I really use are compilers. Hince I then went to C++ and then to C and I have pretty much stuck there. But I have been reading about Perl and it seems to have a nice flow to it. It might be easier to learn than C is for me. C++ ? No problem....
1
2364
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 attached to two rectangles, however, I am having trouble getting the connector object to draw. I have: our $Visio = Win32::OLE->new('Visio.Application') or die "Cannot locate Visio.\n"; $Visio->{'Visible'} = 1; our $VDocs = $Visio->Documents; our...
5
2487
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: 1) When run, the program should check if an argument has been provided. If not, the program should prompt for, and accept input of, a filename from the keyboard. 2) The filename, either passed as an argument or input from the keyboard, should...
66
8168
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 didnt display the html after the perl script executed. Using perl 5.1 and apache 2.2.9 version(apache installed and run without any errors and no warning, perl tested fine) b) Also, when i clicked the html code to submit the upload of the...
0
8704
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9187
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8936
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7776
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3071
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2360
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.