The problem is dbPoll(..,-1), as that will freeze the server until the query has completed. Fix it by using the callback option in dbQuery.
I suspect your 'checkdata' function is the cause of the Network Trouble, as it will be calling dbPoll(..,-1) many times, so update that function first.