Front page | perl.dbi.users |
Postings from August 2006
Problem with DBI retrieving data entered
Thread Next
From:
Russbucket
Date:
August 10, 2006 13:14
Subject:
Problem with DBI retrieving data entered
Message ID:
200608101313.50449.russbucket@nwi.net
Fairly new o using Perl and DBI.
Have mysql database on SUSE 10.0, perl-5.8.7-5.3, mysql-4.1.13-3.6. I am able
to insert the data from an html form but I want to print the last data
entered for verification. I keep getting the following errors (code shown
below):
/usr/bin/perl insertmember.cgi -cw
Content-type: text/html
DBD::mysql::st fetchrow_array failed: fetch() without execute() at
insertmember.cgi line 53.
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax to
use near '' at line 1 at insertmember.cgi line 56.
<html><head><title>Member Information</title></head>
<body>
<h2>Thank You</h2>
Thank you for adding information about a member. Your information was entered
into the database.<p>
</body></html>
Code:
#Insert data
$sth = $dbh->prepare ("INSERT INTO Moses_Lake_Lions (First_Name, Last_Name,
Spouse, email, Home_Phone, Business_Phone, Cell_phone, Occupation_Employer,
Status_Key) Values
('$First_Name', '$Last_Name', '$Spouse', '$email', '$Home_Phone', '$Business_Phone', '$Cell_phone', '$Occupation_Employer', '$Status_Key')");
$rv = $sth->execute ();
#Retrieve data enter for verification
$sth = $dbh->prepare (qq {SELECT First_Name, Last_Name, Spouse, email,
Home_Phone, Business_Phone, Cell_phone, Occupation_Employer, Status_Key FROM
Moses_Lake_Lions WHERE Last_Name = $Last_Name}) or dienice ("Cannot prepare
statement:", $dbh->errstr);
#$rv = $sth->execute ();
while (($First_Name, $Last_Name, $Spouse, $email, $Home_Phone,
$Business_Phone, $Cell_phone, $Occupation_Employer, $Status_Key) =
$sth->fetchrow_array) {
print "$First_Name - $Last_Name - $Spouse - $email - $Home_Phone -
$Business_Phone - $Cell_phone - $Occupation_Employer - $Status_Key) \n";
}
$rv = $sth->execute ();
#$rc = $sth ->finish;
#Disconnect from database
$dbh->disconnect ();
--
Russ
Thread Next
-
Problem with DBI retrieving data entered
by Russbucket