DBD::mysql::st execute failed: MySQL server has gone away at ./topsites.cgi line 463.
$sth->execute;
$SQL = "INSERT INTO aardvarktopsitesdata VALUES ('$at3{num}','$form{url}','$form{title}','$form{description}','$form{urlbanner}','$form{email}','$form{password}')";
&sql_connect;
&sql_do;
$SQL = "INSERT INTO aardvarktopsitesstats VALUES ('$at3{num}','$totalranks','$totalranks','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0')";
&sql_do;
&sql_disconnect;
sub sql_connect {
use DBI;
$DSN = "DBI:$database:$db_name";
$dbh = DBI->connect($DSN,$db_username,$db_password)
¦¦ die "Cannot connect: $DBI::errstr\n" unless $dbh;
return;
}
sub sql_disconnect {
$dbh->disconnect;
}
sub sql_do {
eval{ $sth = $dbh->prepare($SQL); };
if($@){
&sql_disconnect;
print "Content-type: text/html\n\n";
print "An ERROR occurred! $@\n";
exit;
}
else {
$sth->execute;
}
return $sth;
}
sub sql_strip {
$_[0] =~ s/\'/\\'/g;
$_[0] =~ s/\"/\\"/g;
return $_[0];
}
It sounds like the script is somehow dropping the connection to MySQL early. Try removing this section to see if it's causing a problem:
[perl]
if($@){
&sql_disconnect;
print "Content-type: text/html\n\n";
print "An ERROR occurred! $@\n";
exit;
}
[/perl]
If that's not it, it might be a variable scoping issue - check that $DSN or $dbh are not being redefined somewhere else in the script.