title: Fatal error: [] operator not supported for string error on PHP Array in for loop
body: <p>I have this PHP Code:</p>
  
  <pre><code>for($i=1; $i&lt;=$_POST["counter"]; $i++)
  {
      if($_POST["checkbox$i"])
      {
          //select the billing_pdf row
          $sql="SELECT * from billing_pdf_archive where sequence = '".$_POST["checkbox$i"]."' ";
          $rs=mysql_query($sql,$conn);
          while($result=mysql_fetch_array($rs))
          {
              //now select all contacts for the company who receive all accounts emails
              $sql2="SELECT * from contacts where company_sequence = '".$result["customer_sequence"]."' and receive_accountsemails = 'yes' ";
              $rs2=mysql_query($sql2,$conn) or die(mysql_error());
              if(mysql_num_rows($rs2) &gt; 0)
              {
                  while($contacts2=mysql_fetch_array($rs2))
                  {
                      //generate the list of emails address in an array
                      $emails_list[] = $contacts2["email"];
                  }
                  $emails_list = implode(',',$emails_list);
              }
          }
  
          $ins_sql2="INSERT into email_attachments (email_seq, attachment) values ('".$email_sequence."', '".$result["pdf"]."') ";
          $ins_rs2=mysql_query($ins_sql2,$conn) or die(mysql_error());
  
          $up_sql="UPDATE emails set emailto = '".$emails_list."' where sequence = '".$email_sequence."' ";
          $up_rs=mysql_query($up_sql,$conn);
      }
  }
  </code></pre>
  
  <p>but I am getting this error:</p>
  
  <blockquote>
    <p>Fatal error: [] operator not supported for strings in </p>
  </blockquote>
  
  <p>on the line that says:</p>
  
  <pre><code>$emails_list[] = $contacts2["email"];
  </code></pre>
  
  <p>I am using the same array code on other pages (without the for loop) and they work fine</p>
  
  <p>what am I doing wrong?</p>