title: JSON error with PHP/Jquery
body: <p>I am not sure how I do this,
  But baiscly what I want is to show an error message if the user does not have any friends. asking them to add some friends.</p>
  
  <p>The PHP part of this code is returning [false] instead of the error message when it cant find any results in the first mysql.</p>
  
  <p>Here is my jquery code</p>
  
  <pre><code>function fetchfriends(){
  $.getJSON('sys/classes/core.php?task=fetchfriends&amp;userid='+sessionparts[1], function(data) {
  
  
  
  $.each(data, function(key, val) {
      if(val.error)
      {
      $('&lt;div class="myfriendsbar"&gt;'+val.error+'&lt;/div&gt;').appendTo('#mycontacts');
      return false;
      }
      else
      {
  
      $('&lt;div class="myfriendsbar"&gt;&lt;div id="friendsimage'+val.to_userid+'" style="width:32px; height:32px; float:left; margin:3px;"&gt;&lt;/div&gt;'+val.firstname+' '+val.lastname+'&lt;br/&gt;'+val.username+'&lt;/div&gt;').appendTo('#mycontacts');
  
      $('#friendsimage'+val.to_userid).css("background-image", "url(http://bonush.com/beta/sys/classes/photofetch.php?pic="+val.to_userid+":9177156176671)"); 
  
      }
    });
  
  
      });
  </code></pre>
  
  <p>and this is the PHP code</p>
  
  <pre><code>$number_check = mysql_query("SELECT * FROM user_contact WHERE from_userid = '{$this-&gt;userid}'");
  
      if(!mysql_num_rows($number_check))
      {
  
              $arr = array('error' =&gt; "No Friends?&lt;br/&gt;Search above for New users or invite some friends.");
              print json_encode($arr);
      }
      else
      {
              $friendlook = mysql_query("%PRIVATECODE%");
  
              $row = mysql_fetch_assoc($friendlook);
              $rows[] = $row;
              print json_encode($rows);
      }
  </code></pre>