title: PHP addslashes using array
body: <p>I am attempting to update multiple records using one form, but have run into a problem in attempting to use the <strong><code>addslashes</code></strong> function.</p>
  
  <p>The form looks like this:</p>
  
  <pre><code>&lt;form name="form1" method="post" action="editnewscategorysubmit.php"&gt;
  &lt;table width="405"&gt;
  &lt;tr&gt;
  &lt;td width="246"&gt;&lt;span class="link1"&gt;News Category &lt;/span&gt;&lt;/td&gt;
  &lt;td width="146" colspan="2"&gt;&lt;span class="link1"&gt;Delete?&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;input type='text' name='title[]' value='$title' style='width:700px;'&gt;
  &lt;input type='hidden' name='id[]' value='$id'&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;div style='padding-left:8px;'&gt;&lt;a onclick='return confirmSubmit()' href='deletenewscategory.php?id=$id'&gt;&lt;img src='images/delete.jpg' border='0'&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;/td&gt;
  &lt;/tr&gt;                               
  &lt;tr&gt;
  &lt;td&gt;&lt;input name="image" type="image" src="images/submit.png" alt="Submit Form" border="0" /&gt;&lt;/td&gt;
  &lt;td colspan="2"&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The PHP code that processes this looks like this:</p>
  
  <pre><code>$identity = $_REQUEST['id'];
  $title = addslashes($_REQUEST['title']);
  include 'connection.php';
  for($i=0;$i&lt;count($identity);$i++)
  {
  $query = "update newscategory set title = '$title[$i]' where id = '$identity[$i]'";
  $result = mysql_query($query) or die(mysql_error());
  }
  echo "Success. The news categories were updated.";
  include 'return.php';
  </code></pre>
  
  <p>The warning that is returned is:</p>
  
  <blockquote>
    <p>Warning: addslashes() expects parameter 1 to be string, array given in
    /home/u180175506/public_html/editnewscategorysubmit.php on line 71</p>
  </blockquote>
  
  <p>What I am trying to do is to addslashes (or from what I'm reading, using <strong><code>mysql_real_escape_string</code></strong> is preferred!) to each value prior to updating the table. Is there something I'm missing? Thanks!</p>