PHP: Space issue
<p>(made a new question, as instead of having 2 "questions" in my other question)</p>

<p>I am making an PM system for my users.</p>

<p>In the recipient field you type in a full name. When you submit i want to make sure it's the right user he sends to.</p>

<p>And im having a space issue. If I only enter a space in the recipient field, it will return all users name´s inside my "Who did you mean?", in the table. How can i prevent this, and not run the query its empty or only contain spaces? (a nice way)</p>

<p>Here's my code:</p>

<pre><code>$mot = mysql_real_escape_string($_POST['mottagare']);
list($firstname, $lastname) = array_map('ucfirst', explode(' ', $mot, 2));
$qur = mysql_query("
 SELECT id, firstname, lastname, 
 (firstname = '$firstname' AND lastname = '$lastname') AS full FROM users 
 WHERE (firstname = '$firstname' AND lastname='$lastname') 
 OR (firstname LIKE '$firstname%' AND lastname LIKE '$lastname%')
 OR firstname LIKE '$firstname%' OR lastname LIKE '$firstname%'
 ORDER BY (firstname = '$firstname' AND lastname='$lastname') DESC");

 if(mysql_num_rows($qur) == 1){

 $get = mysql_fetch_array($qur);
    if($get["full"] == 1){
    echo $get["id"];
    }else{
     echo "Did you mean: ".$get["firstname"]." ".$get["lastname"]." ?";
    }
 }elseif(mysql_num_rows($qur) &gt; 1){
    while($get = mysql_fetch_array($qur)) {
       $name[] = $get["firstname"]." ".$get["lastname"];
   }

   if(count($name) &gt; 1) {
       echo 'Who did you mean?&lt;br&gt;';
   } else {
       echo 'Did you mean: ';
   }
   echo implode('&lt;br&gt;', $name);

 } 
</code></pre>
