I've experienced a problem lately with selecting from the the table, if i didn't define which database i was selecting from, therefore try changing your query to.
Code:
"SELECT username FROM `test`.`clients` WHERE `ip`= '%s'";
and remember to add ; on the end for each query you send.
__________________