title: CodeIgniter, array do not accept string after $this->db->get
body: <p><strong>According this code in the model Etablissements_commanditaires_m :</strong></p>
  
  <pre><code>public  function ajouter()
     {
  ... code ...
  $recuperer = $this-&gt;db-&gt;get($this-&gt;table)-&gt;result_array();
  $recuperer['quantite_lignes'] = $this-&gt;db-&gt;count_all_results($this-&gt;table);
  $recuperer['number'] = 5;
  $recuperer['text'] = 'blabla';
  </code></pre>
  
  <p>The last line $recuperer['text'] = 'blabla'; makes error.</p>
  
  <p>But the line $recuperer['number'] = 5; do not makes error.</p>
  
  <p>The coming errors are : Illegal string offset or Undefined offset: 0</p>
  
  <p><strong>And this code in the controller :</strong></p>
  
  <pre><code>$etablissements_commanditaires = $this-&gt;etablissements_commanditaires_m-&gt;ajouter();
  $html['quantite_lignes'] = $etablissements_commanditaires['quantite_lignes'];
  ... code ...
  $i=0;
  foreach ($etablissements_commanditaires as $enregistrement)
              {
              echo 'aa'.$enregistrement['id_etablissement_payeur'].'bb'; // Makes the first error.
              ...
              }
  </code></pre>
  
  <p>The errors are :</p>
  
  <pre><code>&lt;p&gt;Severity: Warning&lt;/p&gt;
  &lt;p&gt;Message:  Illegal string offset 'id_etablissement_payeur'&lt;/p&gt;
  &lt;p&gt;Filename: ETABLISSEMENTS_COMMANDITAIRES/etablissements_commanditaires_c.php&lt;/p&gt;
  &lt;p&gt;Line Number: 240&lt;/p&gt;
  
  &lt;/div&gt;aa5bb&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt;
  
  &lt;h4&gt;A PHP Error was encountered&lt;/h4&gt;
  
  &lt;p&gt;Severity: Warning&lt;/p&gt;
  &lt;p&gt;Message:  Illegal string offset 'id_etablissement_payeur'&lt;/p&gt;
  &lt;p&gt;Filename: ETABLISSEMENTS_COMMANDITAIRES/etablissements_commanditaires_c.php&lt;/p&gt;
  &lt;p&gt;Line Number: 243&lt;/p&gt;
  
  &lt;/div&gt;&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt;
  
  &lt;h4&gt;A PHP Error was encountered&lt;/h4&gt;
  
  &lt;p&gt;Severity: Warning&lt;/p&gt;
  &lt;p&gt;Message:  Illegal string offset 'id_etablissement_payeur'&lt;/p&gt;
  &lt;p&gt;Filename: ETABLISSEMENTS_COMMANDITAIRES/etablissements_commanditaires_c.php&lt;/p&gt;
  &lt;p&gt;Line Number: 254&lt;/p&gt;
  
  &lt;/div&gt;&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt;
  
  &lt;h4&gt;A PHP Error was encountered&lt;/h4&gt;
  
  &lt;p&gt;Severity: Notice&lt;/p&gt;
  &lt;p&gt;Message:  Undefined offset: 0&lt;/p&gt;
  &lt;p&gt;Filename: ETABLISSEMENTS_COMMANDITAIRES/etablissements_commanditaires_c.php&lt;/p&gt;
  &lt;p&gt;Line Number: 260&lt;/p&gt;
  </code></pre>
  
  <p>How can I set a string to $recuperer['text'], without having error ?</p>
  
  <p><strong>An other case looking to be the same problem, and then wondering if my CodeIgniter/PHP is ok ?</strong></p>
  
  <p>PHP => PHP Version 5.5.9-1ubuntu4.3</p>
  
  <p>CodeIgniter => 2.2.0</p>
  
  <pre><code>$this-&gt;db-&gt;select('id_etablissement_payeur, nom');
  $this-&gt;db-&gt;where('id_etablissement_payeur',$enregistrement['id_etablissement_payeur']);
  $get_RESULTAT_etablissements_payeurs = $this-&gt;db-&gt;get('etablissements_payeurs');
  $result_etablissements_payeurs = $get_RESULTAT_etablissements_payeurs-&gt;result_array();
  
  echo '&lt;pre&gt;';
  print_r($result_etablissements_payeurs);
  echo '&lt;/pre&gt;';
  
  echo $result_etablissements_payeurs[0]['id_etablissement_payeur'] . ' - '; //Line Number: 279
  echo $result_etablissements_payeurs[0]['nom']; //Line Number: 280
  </code></pre>
  
  <p>The print_r gives the good result with offset 0 :</p>
  
  <pre><code> &lt;pre&gt;Array
  (
      [0] =&gt; Array
          (
              [id_etablissement_payeur] =&gt; 4
              [nom] =&gt; Etablissement payeur N° 4
          )
  
  )
  &lt;/pre&gt;4 - Etablissement payeur N° 4&lt;pre&gt;Array
  (
      [0] =&gt; Array
          (
              [id_etablissement_payeur] =&gt; 1
              [nom] =&gt; Etablissement payeur N° 1
          )
  
  )
  &lt;/pre&gt;1 - Etablissement payeur N° 1&lt;pre&gt;Array
  (
      [0] =&gt; Array
          (
              [id_etablissement_payeur] =&gt; 1
              [nom] =&gt; Etablissement payeur N° 1
          )
  
  )
  etc.
  </code></pre>
  
  <p>But the 2 echo makes an  Undefined offset: 0 error :</p>
  
  <pre><code>&lt;p&gt;Severity: Notice&lt;/p&gt;
  &lt;p&gt;Message:  Undefined offset: 0&lt;/p&gt;
  &lt;p&gt;Filename: ETABLISSEMENTS_COMMANDITAIRES/etablissements_commanditaires_c.php&lt;/p&gt;
  &lt;p&gt;Line Number: 279&lt;/p&gt;
  
  &lt;/div&gt; - &lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt;
  
  &lt;h4&gt;A PHP Error was encountered&lt;/h4&gt;
  
  &lt;p&gt;Severity: Notice&lt;/p&gt;
  &lt;p&gt;Message:  Undefined offset: 0&lt;/p&gt;
  &lt;p&gt;Filename: ETABLISSEMENTS_COMMANDITAIRES/etablissements_commanditaires_c.php&lt;/p&gt;
  &lt;p&gt;Line Number: 280&lt;/p&gt;
  
  &lt;/div&gt;&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt;
  etc.
  </code></pre>
  
  <p>This is very strange, because offset 0 does exist, or I missed something somewhere.</p>
  
  <p>Any idea ?</p>