Problem with DBI retrieving data entered
am 10.08.2006 22:13:50 von RussbucketFairly 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 ab=
le=20
to insert the data from an html form but I want to print the last data=20
entered for verification. I keep getting the following errors (code shown=
=20
below):
/usr/bin/perl insertmember.cgi -cw
Content-type: text/html
DBD::mysql::st fetchrow_array failed: fetch() without execute() at=20
insertmember.cgi line 53.
DBD::mysql::st execute failed: You have an error in your SQL syntax; check =
the=20
manual that corresponds to your MySQL server version for the right syntax t=
o=20
use near '' at line 1 at insertmember.cgi line 56.
Thank You
Thank you for adding information about a member. Your information was enter=
ed=20
into the database.
Code:
#Insert data
$sth =3D $dbh->prepare ("INSERT INTO Moses_Lake_Lions (First_Name, Last_Nam=
e,=20
Spouse, email, Home_Phone, Business_Phone, Cell_phone, Occupation_Employer,=
=20
Status_Key) Values=20
('$First_Name', '$Last_Name', '$Spouse', '$email', '$Home_Phone', '$Busines=
s_Phone', '$Cell_phone', '$Occupation_Employer', '$Status_Key')");
$rv =3D $sth->execute ();
#Retrieve data enter for verification
$sth =3D $dbh->prepare (qq {SELECT First_Name, Last_Name, Spouse, email,=20
Home_Phone, Business_Phone, Cell_phone, Occupation_Employer, Status_Key FRO=
M=20
Moses_Lake_Lions WHERE Last_Name =3D $Last_Name}) or dienice ("Cannot prepa=
re=20
statement:", $dbh->errstr);
#$rv =3D $sth->execute ();
while (($First_Name, $Last_Name, $Spouse, $email, $Home_Phone,=20
$Business_Phone, $Cell_phone, $Occupation_Employer, $Status_Key) =
$sth->fetchrow_array) {
=A0 =A0print "$First_Name - $Last_Name - $Spouse =A0- $email - $Home_Phone =
-=20
$Business_Phone - $Cell_phone - $Occupation_Employer - $Status_Key) \n";
=A0 =A0}
$rv =3D $sth->execute ();
#$rc =3D $sth ->finish;
#Disconnect from database
$dbh->disconnect ();
--=20
Russ