09-10-2017, 08:22 PM
Ok. That makes sense. I will show you what to change and why it will help.
//I was assuming the user id was valid. Let's not do that.
to
//make the query by itself
//see if there are any results
if there are, grab the first (only) one
//Now, change the logic in your input class to only put in the value if there was one found when searching
//I'm going to share this as a pastebin link so I can space it out better without it being confusing.
https://pastebin.com/2CqLUa0F
If that isn't right, it's pretty close. I may have concatenated something wrong off the top of my head, but it's pretty close.
//I was assuming the user id was valid. Let's not do that.
Code:
$name = $db->query('SELECT username FROM users WHERE id = ?",array($ref))->first();
//make the query by itself
Code:
$nameQ = $db->query('SELECT username FROM users WHERE id = ?",array($ref));
Code:
$nameC = $nameQ->count();
if there are, grab the first (only) one
Code:
if($nameC > 0){
Code:
$name = $nameQ->first();
Code:
}
//Now, change the logic in your input class to only put in the value if there was one found when searching
//I'm going to share this as a pastebin link so I can space it out better without it being confusing.
https://pastebin.com/2CqLUa0F
If that isn't right, it's pretty close. I may have concatenated something wrong off the top of my head, but it's pretty close.