Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Problems inserting two records.
Old 05-05-2005, 11:32 AM Problems inserting two records.
Jared's Avatar
Skilled Talker

Posts: 52
Location: St. Anthony, ID
Trades: 0
I want to insert data into two columns at once. For example, in a guestbook script the name and email fields. I want the name to go into the names field and the email to go into the email field. Pretty straightforward I think. Here's my code:

Code:
#!/usr/bin/perl -Tw

require "/home/jaredmg/public_html/cgi-bin/formprocessor.cgi";
&ReadParse (*input);

$name= $input{'name'};
$codeemail= $input{'email'};



use DBI;
$dbh = DBI->connect("DBI:mysql:jaredmg_form:localhost","jaredmg_jaredmg","springer");
$dbh->do("insert into form 
  (firstname) values ('$name')");

my $sth = $dbh->prepare(qq{
    select firstname from form
});
$sth->execute();
print "content-type: text/html\n\n";
print "<html><body>";
while (my ($firstname) = 
    $sth->fetchrow_array())
{
     print "$firstname<br>";
}
$sth->finish();

$dbh->do("insert into form 
  (email) values ('$codeemail')");

my $stn = $dbh->prepare(qq{
    select email from form
});
$stn->execute();
while (my ($email) = 
    $stn->fetchrow_array())
{
     print "$email<br>";
}
$stn->finish();

print "</body></html>";
For my second function (codeemail) I switched the variable from sth to stn because Apache said that their was a variable problem. After switching those, the problem went away. The problem is is that I think sth is specifically written in the DBI module. Whatever I'm doing, it's just not working! The first field works fine, but the secod command will not work.

Any help is greatly appreciated.
Jared is offline
Reply With Quote
View Public Profile Visit Jared's homepage!
 
 
Register now for full access!
Old 05-05-2005, 12:04 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
Jared, this is Perl isn't it? It don't look like PHP much, you need to be at this forum for help with Perl
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 05-05-2005, 06:40 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Thread moved.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 05-06-2005, 08:48 PM
Jared's Avatar
Skilled Talker

Posts: 52
Location: St. Anthony, ID
Trades: 0
Oh, sorry. Yes it is perl, I just figured it was appropriate because it dealt with MySQL.
Jared is offline
Reply With Quote
View Public Profile Visit Jared's homepage!
 
Reply     « Reply to Problems inserting two records.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.52746 seconds with 12 queries