title: Trying to get property of non-object and undefined index erroe
body: <p>I just migrated a site based on custom CMS to new server. After migrating I am getting notices and warnings all over the admin area where content can be edited. </p>
  
  <pre><code>Notice: Trying to get property of non-object in database.php on line 69
  Notice: Undefined index: in database.php on line 69
  </code></pre>
  
  <p>Following are the functions which are being used in the process:</p>
  
  <pre><code>function dbQuerySafener($query,$params=false) {
      $link= db_connect();
      if ($params) {
         foreach ($params as &amp;$v) {
            $v = mysqli_real_escape_string($link,$v);
         }
  
         $sql_query = vsprintf( str_replace("?","'%s'",$query), $params );
      } else {
      $sql_query = $query;
   }
   return $sql_query;
  }
  
  // query returning ARRAY (many rows)
   function dbArray($query,$params=false) {
     $link= db_connect();
     $table_result=array();
     $r=0;
     $sql = dbQuerySafener($query, $params);
     $result = mysqli_query($link,$sql) or die(mysqli_error($link)." 
     &lt;br&gt;".$sql);
     while($row = mysqli_fetch_assoc($result)) {
         $arr_row=array();
         $c=0;
         while ($c &lt; mysqli_num_fields($result)) {
            $col = mysqli_fetch_field($result);
            $arr_row[$col -&gt; name] = $row[$col -&gt; name]; // line 69
            $c++;
         }
      $table_result[$r] = $arr_row;
      $r++;
      }
      return $table_result;
    }
  </code></pre>
  
  <p>It is working as follows:
  A sql query will be passed to dbArray function, for example: </p>
  
  <pre><code> $sql = "SELECT `id`, `emailAddress`, `name` FROM `gcms_users` 
   WHERE `active`=?";
   $data = dbArray($sql, array(1));
  </code></pre>
  
  <p>EXPECTED RESULT:
  The above two functions will fetch the results from database which should contains field name and its value, example:</p>
  
  <pre><code>  Array ( [0] =&gt; Array ( [id] =&gt; 1 [emailAddress] =&gt; admin@email.com 
    [name] =&gt; John ) [1] =&gt; Array ( [id] =&gt; 1 [emailAddress] =&gt; 
    paul@email.com [name] =&gt; Paul ) ) 
  </code></pre>
  
  <p>ACTUAL RESULT:</p>
  
  <pre><code>  Array ( [0] =&gt; Array ( [id] =&gt; 1 [emailAddress] =&gt; admin@email.com [name] =&gt; John ) [1] =&gt; Array ( [] =&gt; ) )
  </code></pre>
  
  <p>There is some problem with dbArray() function while fetching the rows but I am not getting that what is missing here. Your help will be highly appreciated.</p>
  
  <p>Thank you.</p>