print "\nadding url $addurl to table sajter"; &runsql("insert into ah reason='updated' add=$serverid") print "->\n"; #end debug info sub runsql { my $myquery=$_[0]; my $exitonerror=$_[1] if($_[1]); my $starttime=time(); unless($dbh){ $sqldebug .= "\nTry SQL: connect to db $hostname, 'uptime_admin'"; $dbh = Mysql->Connect($hostname, 'uptime_admin', 'loguser', 'poopypants') or die "Can not connect to db\nINFO: $sqldebug"; $sqldebug .= "\nConnect OK'"; } $sqldebug .= "\nTry $myquery"; $runsql_sth = $dbh->query($myquery); my $endtime=time(); if($runsql_sth){ $numrows=$runsql_sth->affectedrows; $sqldebug .= " - $numrows rows"; }else{ $errmsg = $dbh->errmsg(); $sqldebug .= "\n -- ERROR -- '$errmsg' "; if($exitonerror){ die "severe SQL error occurred INFO: $sqldebug"; } } $sqldebug .= sprintf " -- Done in %d secs ",$endtime-$starttime; return $runsql_sth; }