title: MYSQL column specified twice INSERT
body: <p>I hope I can get some help.</p>
  
  <p>I am making a add task table where a user can input the title, a desc, user assigned and other things into the specifications of the task. There's an option to add another row (task) and this is generated using ajax. </p>
  
  <p>Each input in the row has an original name (name="tasktitle0", name="privacy0") and when you add a new row they have the same name except a variable is incremented and is attached to the end of if ex (tasktitle1, and taskprivacy1 so on and so forth). </p>
  
  <p>when I submit the form I subst() the name of the input, trimming the first four characters and then trimming the last character so the name becomes "title", "privacy" just as the columns in the database that im going to insert them. </p>
  
  <p>if I only submit one task, the app works. but if I create a new row(task) MySql gives me an error saying that </p>
  
  <p>There was an error. Error #Column 'privacy' specified twice</p>
  
  <p>i know why is doing it, I just need to know how I could fix this issue.</p>
  
  <p>heres the php where im trimming the names: </p>
  
  <pre><code>if ($_GET['s'] == "Y") {
      $str2 = '';
      foreach ($_POST as $p =&gt; $v) {
          if (substr($p, 0, 4) != "flag" &amp;&amp; $p != "key" &amp;&amp; substr($p, 0, 4) == "task") {
              if (!empty($v)) {
                  $str2 .= mb_substr(substr($p, 4), 0, -1) . "='" . addslashes($v) . "',";
              } else {
                  $str2 .= substr($p, 4) . "=NULL,";
              }
          }
      }
  }
  </code></pre>
  
  <p>Here's where I'm inserting it:</p>
  
  <pre><code>$sql3 = "INSERT INTO nameofDB.tablename SET ";
  $sql3 .= $str2;
  $sql3 = substr($sql3, 0, -1);
  
  if ($str2 != '') {
      if ($r2 = mysql_query($sql3, $Link)) {
          $mess = "Successfully saved support ticket.";
      } else {
          $mess = "There was an error. Error #" . mysql_error($Link);
          echo $mess . "&lt;br&gt;";
          echo $sql3;
          exit;
      }
  }
  </code></pre>
  
  <p>and here's the error it displays:</p>
  
  <p>this is when I do 2 rows (tasks), I know that in one query im telling it to instert into the columns twice but how could I fix this? ideas?</p>
  
  <blockquote>
    <p>There was an error. Error #Column 'privacy' specified twice
    INSERT INTO dbname.tablename SET ticketNum='95240560',title='d',tdesc='asd',datefrom='02/26/2013',cat='PERSONAL',userid='3171',status='INACTIVE',priority='MEDIUM',privacy='PUBLIC',ticketNum='95240560',title='sad',tdesc='d',datefrom='02/28/2013',cat='BEREAVEMENT',userid='1949',status='COMPLETED',priority='HIGH',privacy='PRIVATE'</p>
  </blockquote>