title: MySQL join results different in PHP?
body: <p>I have a query:</p>
  
  <pre><code>SELECT * FROM categorys 
  LEFT JOIN category_info ON categorys.cat_id=category_info.cat_id 
  WHERE `cat_name` = 'aname'
  ORDER BY `cat_order`
  </code></pre>
  
  <p>When I run this in phpMyAdmin I get an cat_id back regardless of if there is a match in the second table.</p>
  
  <p>However, when I run this query in my PHP code I get a blank cat_id back, as shown by this print_r():</p>
  
  <blockquote>
    <p>Array ( [cat_id] => [cat_name] => baths [type] => main [cat_order] =>
    99 [cat_img] => [display] => 1 [deleted] => 0 [desc_id] => [desc] =>
    [text] => )</p>
  </blockquote>
  
  <p>Why would there be a different result when the query is exactly the same?</p>
  
  <p>EDIT:
  My PHP code:</p>
  
  <pre><code>$getcatidsql = "SELECT * FROM categorys 
  LEFT JOIN category_info ON categorys.cat_id=category_info.cat_id 
  WHERE `cat_name` = '{$cname}'
  ORDER BY `cat_order";   
  $getcatidresult = $db-&gt;query( $getcatidsql );
  $catdata = $db-&gt;fetchRow( $getcatidresult );
  
  function query() {
    $this-&gt;query_total++;
    if (func_num_args() == 1) {
      $sql = func_get_arg(0);
    } else {
      $args = func_get_args();
      for ($i=1;$i&lt;count($args);$i++) if (!is_numeric($args[$i])) $args[$i] = '"'.mysql_real_escape_string($args[$i]).'"';
      $sql = vsprintf(array_shift($args),$args);
    }
    if ($result = mysql_query($sql,$this-&gt;db_connection)) {
      return $result;
    } else {
      $this-&gt;dberror( $this-&gt;db_connection, $sql );
    }
  }
  
  function fetchRow($result,$type=MYSQL_ASSOC)
  {
      if($result)
          $row = mysql_fetch_array($result,$type);
      return $row;
  }
  </code></pre>