title: htmlentities() called in JSON. Storing Arrays in MySQL DB
body: <p>I have an array of users and book ids. I have used a <code>foreach</code> loop to create entries in the database for each item in the array. <b>One problem though!</b> I have only ever used the <code>$stmt-&gt;bind_params</code> when binding strings so when I tried it with this I got this <code>php</code> error: </p>
  
  <blockquote>
    <p>Warning: mysqli_stmt::bind_param() excepts parameter 1 to be string, array given.</p>
  </blockquote>
  
  <p>My PHP Code (Get the POST param):</p>
  
  <pre><code>if(isset($_POST['watch'])){
  $jsonwatch = $_POST['watch'];
  $array = json_decode($jsonwatch, true);
  foreach ($array as $item){
      $response["error"] =! ($db_watch-&gt;storeClass($array['attendees'], $array['lesson_iDs']));
  }
  </code></pre>
  
  <p>My PHP Code (<code>storeClass()</code> function to Database):</p>
  
  <pre><code>public function storeClass($attendees, $lesson_iDs) {
      $stmt = $this-&gt;conn-&gt;prepare("INSERT INTO watch (date, user_id, lesson_id) VALUES(NOW(), ?, ?)");
      $stmt-&gt;bind_param($attendees, $lesson_iDs);
      $result = $stmt-&gt;execute();
      if(!$result){
          echo '\n';
          printf("Error : %s.\n", $stmt-&gt;error);
          echo '\n';
          echo '\n';
      }
  
      $stmt-&gt;close();
  
      // result
      return $result;
  }
  </code></pre>
  
  <h2>UPDATE!</h2>
  
  <p><b>I forgot to mention that the array is coming from my Android Client the code for which is below. I take 2 <code>ArrayList</code>s and convert them into arrays for php:</b></p>
  
  <pre><code>ArrayList&lt;String&gt; attendees = (ClassesAdapter.getAttendees());
  ArrayList&lt;Integer&gt; lesson_iDs = (Lesson_ClassesAdapter.getLesson_IDs());
  
  attendees.toArray();
  lesson_iDs.toArray();
  watch = new Watch(attendees, lesson_iDs);
  </code></pre>
  
  <p><strong>JSON:</strong></p>
  
  <p>Something is calling <code>htmlentities()</code> that might be the reason but I don't know how to resolve that. </p>
  
  <pre><code>var_dump($jsonwatch): {&amp;quot;73327&amp;quot;,&amp;quot;883992&amp;quot;],&amp;quot;id&amp;quot;:0,&amp;quot;lesson_iDs&amp;quot;:[1],&amp;quot;lesson_id&amp;quot;:0}
  </code></pre>