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.
|