title: Inserting an array of lines into an SQL table
body: <p>I would really appreciate if you would take a look at this piece of code:</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['add'])) {
  
  $self = $_SERVER['PHP_SELF']; //the $self variable equals this file
  $ipaddress = ("$_SERVER[REMOTE_ADDR]"); //the $ipaddress var equals users IP
  
  //connect
  $connect = mysql_connect($host,$username,$password) or die('&lt;p class="error"&gt;Unable to 
  connect to the database server at this time.&lt;/p&gt;');
   mysql_select_db($database,$connect) or die('&lt;p class="error"&gt;Unable to connect to the 
  database at this time.&lt;/p&gt;');
  
  //fetch data
  $data = htmlspecialchars($_POST['list']);
  $comment =  mysql_real_escape_string($_POST['comment']);
  
  $data_lines = explode( "\r\n", $data );
  $comment_lines = explode( "\r\n", $comment );
  for($i=0;$i&lt;count($data_lines);$i++)
  {
  $data_fields = explode( ",", $data_lines[$i]);
  
    $time = time();
    $queryb = "INSERT INTO coords SET tag='$data_fields[0]', guild='$data_fields[1]', name='$data_fields[2]', base='$data_fields[3]', econ='$data_fields[5]', maxecon='$data_fields[6]', location='$data_fields[4]', comment='$comment_lines[$i]', ipaddress='$ipaddress' ,date='$time';";
  
    // if it succeeds, display message
    if (@mysql_query($queryb))
    {
       echo('&lt;p class="success"&gt;Successful posting of ['.$data_fields[3].']!&lt;/p&gt;');
    }
    else
    {
       echo('&lt;p class="error"&gt;Error could not post ['.$data_fields[3].'] to database!&lt;/p&gt;');
  }
  }//end for loop
  }//end if $_POST['add'] statement
  ?&gt;
  </code></pre>
  
  <p>As you can see, it gets data received from a form's submission and explodes them into lines.</p>
  
  <p>For <code>$data</code>, it explodes it again for each comma.
  It then inserts everything for each comma, in a new column and for each line, on a new row.</p>
  
  <p>Now for <code>$comment</code>, it should be inserting it on a new row for each line, which isn't doing it.
  Been looking and testing at it for a few days now.</p>
  
  <p>The comment column is a varchar of 100 of length.</p>
  
  <p>So basically, it does everything I need it to do except inserting <code>$comment</code> on a new row for every line.</p>