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
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!
 
When You Register, These Ads Go Away!
Old 05-05-2005, 12:04 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
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: www.festerband.com | www.thegourmetpatisserie.co.uk
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
Thread moved.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Scribble Pad MOD for phpBB (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
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

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
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.11729 seconds with 12 queries