Inserting multiple array values in mySQL database

后端 未结 3 1946
-上瘾入骨i
-上瘾入骨i 2021-01-28 15:43

I have two PHP variables, both strings:

$friendslist = \"2323443,7245,284683,345123,8456234,95432\"

$id = \"10288272\";

The structure of the t

3条回答
  •  无人共我
    2021-01-28 16:25

    You are getting this error because you have not declared the $frienduserarray as array any where in your code. Just declare it

     $frienduserarray=array();
    

    before the for loop. After that your code should look like

      $friendarray = explode(",", $friendslist);
      $frienduserarray=array();
      for ($n = 0; $n < count($friendarray); $n++) {
          $friendidpush = "('".$id."','".$friendarray[$n]."'),";
          array_push($frienduserarray, $friendidpush);
      }
    

提交回复
热议问题