Strictly speaking, you don't need to select user id this way. As you just inserted data in the table, then you have call insert_id() function to get autogenerated id. That's all.
As of such "problems" in general - again: you have to isolate that code snippet, add code to verify every single one premise (var_dumping input, selecting raw DB content without conditions, comparing data from db with input (I mean code that compares and outputs the result)) and - if still unable to solve - be able to post both code along with output in your question, to make it sane and answerable.
You have to understand that code doesn't exist in vacuum. It runs on the server with it's distinct environment, it uses a database, it processes some input - ALL THESE THINGS TOTALLY UNKNOWN FOR THE READER - and thus it makes a question that consists of only code totally useless.