The issue is the quoting of the strings in the text fields.
Use a here-document (which enables you to write a nicer looking statement):
sqlite3 database <<END_SQL
    UPDATE stats
    SET downspeed=$DN,
        upspeed=$UP,
        downlocalip="$downlocalip",
        downremoteip="$downremoteip",
        uplocalip="$uplocalip",
        upremoteip="$upremoteip"
    WHERE primkey=1
END_SQL
This is assuming that you have full control over the values in the variables so that you know that they are properly sanitized and won't introduce any SQL injection vulnerability.
From comments:
Doing this over SSH:
ssh user@server sqlite3 database <<END_SQL
    UPDATE stats
    SET downspeed=$DN,
        upspeed=$UP,
        downlocalip="$downlocalip",
        downremoteip="$downremoteip",
        uplocalip="$uplocalip",
        upremoteip="$upremoteip"
    WHERE primkey=1
END_SQL
 
                