Rewrite like this:
snprintf(querystring, MAXQRYLEN,
"SELECT login FROM connections "
"LEFT JOIN contacts ON (contact = contactid) "
"WHERE id = '%s' "
"AND pin = '%s' "
, conn, pin);
Notice those trailing spaces, if you forget one you'll be debugging for hours :-|
The code is uglier and harder to maintain, but if you really cared you would be using Perl instead of C in the first place.... right?