I have written a Perl script to schedule appointments at a clinic. The code puts clients in timeslots for every clinic day. There is a MySQL query that simply gets the nurse names and IDs then makes a drop-down select button beside the client's names in the schedule. When there is more than 9 people scheduled for the day the query hangs the script. It also hangs if there are more that 3 people with the same appointment time and more than 5 people in total for that day. I am completely baffled at why this script would hang under those specific circumstances, especially considering that this section of code has nothing to do with the appointment tables - it only uses the nurses table. Here is the section of code. If I comment out the stuff during the query (in the while loop) it works fine but with no nurse drop-down menu. If I do *ANYTHING* inside the while loop the code hangs. The query works fine under PHPMyAdmin.
if ($in{clinicdate} <= $today) {
my $query="SELECT nurseid, fname, lname FROM nurses ORDER BY fname
+ ASC;";
my $dbh;
my $sth;
$dbh = DBI->connect("DBI:mysql:$dbname", $dbuser, $dbpass,{PrintEr
+ror => 1, RaiseError => 1});
$sth=$dbh->prepare($query);
$sth->execute();
print "$formstart\n\t\t<INPUT TYPE=HIDDEN NAME=\"f\" VALUE=\"Chang
+eNurse\">\n\t\t\t<INPUT TYPE=HIDDEN NAME=\"clinicdate\" VALUE=\"$in{c
+linicdate}\">\n\t\t\t<INPUT TYPE=HIDDEN NAME=\"clientid\" VALUE=\"$cl
+ientid\">\n\t\t<SELECT NAME=\"nurseused\" onchange=\"this.form.submit
+()\">\n\t\t\t<OPTION VALUE=\"\">Nurse</OPTION>";
while (@row=$sth->fetchrow()) {
print "\n\t\t\t<OPTION VALUE=\"$row[0]\"";
if ($nurseused{$clientid} eq $row[0]) {
print " SELECTED";
}
print ">$row[1] $row[2]</OPTION>";
}
$sth->finish;
$dbh->disconnect;
print "\n\t\t\t<OPTION VALUE=\"0\" style=\"background-color:red\">
+NO SHOW!</OPTION>\n\t\t</SELECT>\n</FORM>";
} else {
if ($confirmed{$clientid}==1) {
print " X ";
}
}