Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 16th, 2000, 04:12 AM
Head8k Head8k is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Exeter, Devon, UK
Posts: 1 Head8k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi everyone. I'm new to this forum and very new to PERL - in fact I have no knowledge of it at all so please excuse my ignorance.

I've written a script for a client in ASP that connects to a database and pulls out a few values depending on a number entered in a HTML form element. It's dead straight forward, just about half a dozen lines of code.

I've since found out that the server this script was to reside on doesn't support ASP, only CGI/PERL and I'm stuck. If anyone thinks they could help replicate my script in PERL I'd be very grateful. As yet I don't know whether I'm going to be paid for this job but if I am, I'll go 50/50 with you.

What I'd basically like to know is can PERL be used to connect to a MS Access Database on an Apache Server? If so, is it easy and can it do something like the ASP script below?

Please email me if you want the full source code and an example Access database.

Thanks in advance.

Head8k

----------

<%@ Language = VBscript %>
<%
Dim passedVar, showInfo, infoSQL, objConn

'This variable is comes from the referring page
passedVar=Request.Form("ID")

'use the Primary key for the query.

infoSQL="SELECT FinTime, Forename, Surname FROM runners WHERE StartNo='" & passedVar & "'"

set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open ("driver={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath("mydatabase.mdb"))

set showInfo=objConn.execute(infoSQL)

%>

<html>
<head>
<title></title>
</head>
<body onLoad="self.focus()">
<p>This page will contain other page elements, I'll format it later.

Finishing Time:
<%= showInfo(0) %><br>

Forename:
<%= showInfo(1) %><br>

Surname:
<%= showInfo(2) %><br>
</body>
</html>

----------

Reply With Quote
  #2  
Old August 16th, 2000, 08:23 AM
JSchoof JSchoof is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 82 JSchoof User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 23 m 46 sec
Reputation Power: 13
Well, I dont know if you would really want to use access with apache. Does the situation require it? Is it a large (greater than 3 tables, more than 1000 records) database? If not, there are workarounds. Send me some mail at josh_schoof@yahoo.com.

The perl would look something like this:


#!/perl

use CGI;
use YourDBPackage;
$query = new CGI;
$app = new YourDBPackage;

my $passedVar;
my $showInfo;
my $infoSQL;
my $objConn;


$passedVar = $query->param(ID);

$infoSQL = "SELECT FinTime, Forename, Surname FROM runners WHERE StartNo='$passedVar'";

$objConn = $app->Recordset($infoSQL);

@showInfo = $recset->fetchrow;

print <<HTML;

<html>
<head>
<title></title>
</head>
<body onLoad="self.focus()">
This page will contain other page elements, I'll format it later.

Finishing Time:
$showInfo[0]

Forename:
$showInfo[1]

Surname:
$showInfo[2]
</body>
</html>

And so forth. The only consideration is the "YourDBPackage" bit. I usually make
up a .PM file with some handy DB functions in it, like the Recordset one seen
above. That function looks like:

sub Recordset {
my ($self, $sqlStr) = @_;
my $recset = $db->prepare($sqlStr);
if ($recset) {
$recset->execute;
return $recset;
}
else {Error("",$DBI::errstr)}
}

Just set up your DB connection as "$db" and let er rip.

Josh

[This message has been edited by JSchoof (edited August 16, 2000).]

[This message has been edited by JSchoof (edited August 16, 2000).]

Reply With Quote
  #3  
Old August 16th, 2000, 10:42 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 14
Yes, you should use something like mysql database for a *nix server.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Please can someone replicate this ASP script using PERL

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap