fixing strncpy null terminate bug
closing database when done
die cleans up connection