Someone help this guy out? I'm not a database guy

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

Hello. I frequent another forum, and this guy specifically asked me to help him. Unfortunately I don't use mysql for anything. So I wouldn't know where to begin. Take a look at his post and see if you guys can help him out. Thanx.

Original post by : sk

Please, someone, help me!
http://power.arc.losrios.cc.ca.us/~kwons/cgi-bin/classmates-delete.cgi
Please, visit above address and pick the data you want to delete and press delete button.
Then delete2.cgi suposed to return delete item and new data table. But it's not hapening.
I get fallowing error message, when I check it.
DBD::mysql::st fetchrow_array failed: fetch() without execute() at ./classmates-delete2.cgi line 91.
The script for "classmates-delete2.cgi"
#!/usr/bin/perl
# Invokes a Perl module for connecting to databases
use DBI;
require 'subparseform.lib';
&Parse_Form;
$idnum = $formdata{'idnum'};
#6 Get the delete record
$dbh = DBI->connect("DBI:mysql:kwons", "kwons", '123456');
$cursor = $dbh->prepare("select fname, minitial, lname, miles, cats, dogs, brand from classmates where idnum = '$idnum'");
$cursor->execute;
#11 Delete the record
$dbh = DBI->connect("DBI:mysql:kwons", "kwons", '123456');
$cursor_delete = $dbh->prepare("delete from classmates where idnum = '$idnum'");
$cursor_delete->execute;
#16 Get the entire database after the deletion
$dbh = DBI->connect("DBI:mysql:kwons", "kwons", '123456');
$cursor_new = $dbh->prepare("select fname, minitial, lname, miles, cats, dogs, brand from classmates order by lname");
$cursor_new->execute;
require 'subroutines.lib';
#23 Main Program
&mime
&templatestart("Record Deteted", "lightblue");
print "\n";
print "Record Deleted";
&templatebody
#32 Desplay the record that was deleted
print "\n";
print "The Following Record was Deleted:\n";
print "\n";
#37 Write table based on database information
&theader("border=0 cellpadding=5 cellspacing=1");
&trow7 ("FirstName",
"Mid.Initial",
"LastName",
"MilesfromARC",
"Num.ofCats",
"Num.ofDogs",
"ComputerBrand");
$colorIndex = 0;
while ( @row = $cursor->fetchrow_array ) {
$fname = $row[0];
$minitial = $row[1];
$lname = $row[2];
$miles = $row[3];
$cats = $row[4];
$dogs = $row[5];
$brand = $row[6];
if ($minitial eq "") {
$minitial = "";
}
if ($colorIndex %2 ==0) {
&trow7b($fname, $minitial, $lname, $miles, $cats, $dogs, $brand);
} else {
&trow7a($fname, $minitial, $lname, $miles, $cats, $dogs, $brand);
}
$colorIndex++;
}
&tfooter
print "  \n";
#70-----------------------------------------
print "\n";
print "Here is the New Data Dable:\n";
print "\n";
&theader("border=0 cellpadding=5 cellspacing=1");
&trow7 ("FirstName",
"Mid.Initial",
"LastName",
"MilesfromARC",
"Num.ofCats",
"Num.ofDogs",
"ComputerBrand");
$colorIndex = 0;
while ( @row = $cursor->fetchrow_array ) {
$fname = $row[0];
$minitial = $row[1];
$lname = $row[2];
$miles = $row[3];
$cats = $row[4];
$dogs = $row[5];
$brand = $row[6];
if ($minitial eq "") {
$minitial = "";
}
if ($colorIndex %2 ==0) {
&trow7b($fname, $minitial, $lname, $miles, $cats, $dogs, $brand);
} else {
&trow7a($fname, $minitial, $lname, $miles, $cats, $dogs, $brand);
}
$colorIndex++;
}
&tfooter
print "  \n";
print "Delete More Records |
Add a Record\n";
&templatestop
Please, Help!
Thank you

Pimpin like a pimp with an electrofied pimpin machine!