Hi guys,
I have a small problem with my Perl-CGI script, and I would appreciate if anyone can help me out with this. I'm trying to get this done in two stages. 1st to get a bunch of info from the web and display it (which is working fine), but the 2nd part is, I want to add some of these info into my MySQL table after viewing them (I don't know how to do in Perl). Right now the script immediately adds values to the MySQL table, before I even click on submit button.
Thanks alot in advance.
Following is the script that I'm trying to write. -
-
#!/usr/bin/perl -w
-
use strict;
-
use CGI;
-
use LWP::Simple;
-
use Bio::DB::SwissProt;
-
use DBI;
-
-
my $cgi = new CGI;
-
-
print $cgi->header() .
-
$cgi->start_html( -title => 'Results',
-
-bgcolor => '#6699CC').
-
# HTML table starts...
-
print '<TABLE border="1" cellspacing="0" cellpadding="3" width="80%">' . "\n";
-
......
-
print "<tr><th width='15%'>Entry Name</th><td>" . $id . "</td></tr>\n";
-
print "<tr><th>Accession</th><td>" . $accession . "</td></tr>\n";
-
print "<tr><th>Protein Name</th><td>" . $sequence . "</td></tr>\n";
-
......
-
-
print "<tr><td><INPUT type=\"reset\" name=\"cancel\" value=\"Cancel\"></td>"; print "<td><INPUT type=\"submit\" name=\"update\" value=\"Update\" onsubmit=\"???\"></td></tr>";
-
-
....
-
my $dbh = DBI->connect ("DBI:mysql:database:xxx.xxx.xxx.xxx","root","password") or die "Error: $DBI::errstr\n";
-
my $sql = "INSERT INTO table (a, b, c) VALUES ('$accession', '$sequence', '$id')";
-
my $in = $dbh->prepare($sql);
-
$in->execute;
-
9 3302
I'm a beginner at perl, and have never used it for CGI development, but I think I see your problem -- your code is adding to the database right below displaying them.
You can set up your page as a form
[display values]
<form action="insert. cgi">
<input type = "submit">
</form>
Then, in insert.cgi, you add the values to your mySQL database.
Or something of that nature ... since I've never used perl for CGI :)
thanks kaioshin00 for your reply.
does anyone know why i can't execute the subroutine like this, and any other ways?: -
print $cgi->button(-name=>'update', -value=>'UPDATE', -onClick=>&update_db);
-
-
sub update_db{
-
my $dbh = DBI->connect ("DBI:mysql:......);
-
my $sql = "INSERT INTO .......
-
}
-
Appreciate it!
numberwhun 3,509
Recognized Expert Moderator Specialist
thanks kaioshin00 for your reply.
does anyone know why i can't execute the subroutine like this, and any other ways?: -
print $cgi->button(-name=>'update', -value=>'UPDATE', -onClick=>&update_db);
-
-
sub update_db{
-
my $dbh = DBI->connect ("DBI:mysql:......);
-
my $sql = "INSERT INTO .......
-
}
-
Appreciate it!
Can we please learn how to use code tags?! There is a sample in the REPLY GUIDELINES to the right of the message window when posting. Please read it and follow the example.
Thank you!
-Moderator
KevinADC 4,059
Recognized Expert Specialist
thanks kaioshin00 for your reply.
does anyone know why i can't execute the subroutine like this, and any other ways?: -
print $cgi->button(-name=>'update', -value=>'UPDATE', -onClick=>&update_db);
-
-
sub update_db{
-
my $dbh = DBI->connect ("DBI:mysql:......);
-
my $sql = "INSERT INTO .......
-
}
-
Appreciate it!
onClick is to initiate javascript code, not perl code.
KevinADC 4,059
Recognized Expert Specialist
Can we please learn how to use code tags?! There is a sample in the REPLY GUIDELINES to the right of the message window when posting. Please read it and follow the example.
Thank you!
-Moderator
Looks like MIller left you hanging. Give yourself a break Jeff, don't worry about the code tags, what's Mary gonna do, fire you? ;)
numberwhun 3,509
Recognized Expert Moderator Specialist
Looks like MIller left you hanging. Give yourself a break Jeff, don't worry about the code tags, what's Mary gonna do, fire you? ;)
Nah, not in my nature. I am too anal to let it go. :-)
What did happen to Miller? I haven't seen him. Haven't had a response to PM's. Mary says she saw him online but no hide nor hair.
KevinADC 4,059
Recognized Expert Specialist
Nah, not in my nature. I am too anal to let it go. :-)
What did happen to Miller? I haven't seen him. Haven't had a response to PM's. Mary says she saw him online but no hide nor hair.
hehehe...
I have no clue what happend to M. I hope he's on a tropical island dancing naked with the beautiful natives. I'll drop him an email and see if he responds. He might have just got burned out with the whole forum posting stuff, it happens.
numberwhun 3,509
Recognized Expert Moderator Specialist
hehehe...
I have no clue what happend to M. I hope he's on a tropical island dancing naked with the beautiful natives. I'll drop him an email and see if he responds. He might have just got burned out with the whole forum posting stuff, it happens.
True, it certainly does! Let me know if you hear from him. Just want to make sure he's ok.
heheheeee....yo u guys are funny.
happy chatting!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mark Wilson CPU |
last post by:
This must be easy, but I'm missing something...
I want to execute a Perl script, and capture ALL its output into a PHP
variable. Here are my 2 files:
-------------------------------------
test3.pl
-------------------------------------
print "PERL Hello from Perl! (plain print)<br>\n";
print STDERR "PERL This is text sent to STDERR<br>\n";
$output="PERL Some output:<br>\n";
for ($i=0; $i<5; $i++) {
|
by: John Smith |
last post by:
Hello,
I have a rather odd question. My company is an all java/oracle shop.
We do everything is Java... no matter what it is... parsing of text
files, messaging, gui you name it. My question is this... is Perl so
much better at parsing text files and outputing that we would see a
substantial speed increase? We process about 10 million records in
flat files a day for reformatting before putting them in a DB.
Also, when it comes to...
|
by: Fred Ma |
last post by:
Hello,
This is not a troll posting, and I've refrained from
asking because I've seen similar threads get all
nitter-nattery. But I really want to make a decision
on how best to invest my time. I'm not interested on
which language is better in *general*, just for my
purpose. My area of research is in CAD algorithms,
and I'm sensing the need to resort to something more
expedient than C++, bash scripting, or sed scripting.
|
by: surfunbear |
last post by:
I've read some posts on Perl versus Python and studied a bit of my
Python book.
I'm a software engineer, familiar with C++ objected oriented
development, but have been using Perl because it is great for pattern
matching, text processing, and automated testing. Our company is really
fixated on risk managnemt and the only way I can do enough testing
without working overtime (which some people have ended up doing) is by
automating my...
|
by: David F. Skoll |
last post by:
Hi,
I'm tearing my hair out on this one. I'm trying to embed a Perl
interpreter into a C program. I need to be able to create and destroy
the interpreter periodically, but will never actually have two interpreters
at the same time.
On Red Hat Linux 7.3 with Perl 5.6.1, the attached program segfaults. On
Red Hat 9 with Perl 5.8.0, it works perfectly. Save the program code
as "test-embed-perl.c" and the build script as "buildte". ...
| |
by: Julia Bell |
last post by:
I would like to run the same script on two different platforms. The
directory in which the script(s) will be stored is common to the two
platforms. (I see the same directory contents regardless of which
platform I use to access the directory.)
Platform 1: perl is installed in /tps/bin/perl. CPAN modules are available
Perl is also installed in /usr/bin/perl Platform 1, but the modules are
not accessible with this version.
Platform...
|
by: Xah Lee |
last post by:
Sort a List
Xah Lee, 200510
In this page, we show how to sort a list in Python & Perl and also
discuss some math of sort.
To sort a list in Python, use the “sort” method. For example:
li=;
|
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.
|
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
|
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |