Fatal error: [] operator not supported for string error on PHP Array in for loop

前端 未结 2 1872
故里飘歌
故里飘歌 2021-01-24 17:47

I have this PHP Code:

for($i=1; $i<=$_POST[\"counter\"]; $i++)
{
    if($_POST[\"checkbox$i\"])
    {
        //select the billing_pdf row
        $sql=\"SELE         


        
相关标签:
2条回答
  • 2021-01-24 18:36

    You have already used $emails_list as a string some where in your page like $emails_list = 7;

    and again using it like

    $emails_list[] = array(1,2,4);

    0 讨论(0)
  • 2021-01-24 18:39

    you fill the array $emails_list[] in the second while with $contacts2["email"]. in the next line, you implode the array to a string.

    for the next result (first while loop) $emails_list is a string. now you can't convert a string to an array

    try this:

            $emailsListData = array();
            while($contacts2=mysql_fetch_array($rs2))
            {
                //generate the list of emails address in an array
                $emailsListData[] = $contacts2["email"];
            }
            $emails_list = implode(',',$emailsListData);
    
    0 讨论(0)
提交回复
热议问题