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

前端 未结 2 1876
故里飘歌
故里飘歌 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: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);
    

提交回复
热议问题