I have this PHP code that selects one simple value:
$name = $mysqli->query('SELECT name FROM users WHERE id = ' . $id . ' LIMIT 1')->fetch_object()->name;
Now if the result is 0, it throws an error.
I want instead to return a default value like "No name" if there are no results.
Any suggestions?