title: Inserting Data to MySQL, Double Quotes Added to Fields
body: <p>I've got a script that imports data to a MySQL table and when inserting, VARCHAR and TEXT fields have double quotes on the beginning and end.  I am using <code>addslashes</code> because some of the fields are supposed to have single quotes, double quotes, commas, and semi-colons.  Here's my code:</p>
  
  <pre><code>$csvfile = fopen($csv_file, 'r');
  $theData = fgets($csvfile);
  $i = 0;
  $imports = array();
  
  while (!feof($csvfile))
  {
     $csv_data[] = fgets($csvfile, 1024);
     $data = explode(",", $csv_data[$i]);
     $insert_csv = array();
  
     $insert_csv['id'] = md5($EventID.$PerformerID);
     $insert_csv['EventID'] = addslashes($data[0]);
     $insert_csv['Event'] = addslashes($data[1]);
     $insert_csv['PerformerID'] = addslashes($data[2]);
     $insert_csv['Performer'] = addslashes($data[3]);
     $insert_csv['Venue'] = addslashes($data[4]);
     $insert_csv['VenueID'] = addslashes($data[5]);
     $insert_csv['VenueStreetAddress'] = addslashes($data[6]);
     $insert_csv['DateTime'] = addslashes($data[7]);
     $insert_csv['PCatID'] = addslashes($data[8]);
     $insert_csv['PCat'] = addslashes($data[9]);
     $insert_csv['CCatID'] = addslashes($data[10]);
     $insert_csv['CCat'] = addslashes($data[11]);
     $insert_csv['GCatID'] = addslashes($data[12]);
     $insert_csv['GCat'] = addslashes($data[13]);
     $insert_csv['City'] = addslashes($data[14]);
     $insert_csv['State'] = addslashes($data[15]);
     $insert_csv['StateID'] = addslashes($data[16]);
     $insert_csv['Country'] = addslashes($data[17]);
     $insert_csv['CountryID'] = addslashes($data[18]);
     $insert_csv['Zip'] = addslashes($data[19]);
     $insert_csv['TicketsYN'] = addslashes($data[20]);
     $insert_csv['IMAGEURL'] = addslashes($data[23]);
  
     $query = "INSERT IGNORE INTO table_name(`id`, `EventID`, `Event`, `PerformerID`, `Performer`, `Venue`, `VenueID`, `VenueStreetAddress`, `DateTime`, `PCatID`, `PCat`, `CCatID`, `CCat`, `GCatID`, `GCat`, `City`, `State`, `StateID`, `Country`, `CountryID`, `Zip`, `TicketsYN`, `IMAGEURL`)
  VALUES('{$insert_csv['id']}','{$insert_csv['EventID']}','{$insert_csv['Event']}','{$insert_csv['PerformerID']}','{$insert_csv['Performer']}','{$insert_csv['Venue']}','{$insert_csv['VenueID']}','{$insert_csv['VenueStreetAddress']}','{$insert_csv['DateTime']}','{$insert_csv['PCatID']}','{$insert_csv['PCat']}','{$insert_csv['CCatID']}','{$insert_csv['CCat']}','{$insert_csv['GCatID']}','{$insert_csv['GCat']}','{$insert_csv['City']}','{$insert_csv['State']}','{$insert_csv['StateID']}','{$insert_csv['Country']}','{$insert_csv['CountryID']}','{$insert_csv['Zip']}','{$insert_csv['TicketsYN']}','{$insert_csv['IMAGEURL']}')";
  
     $n = mysql_query($query);
     if(!mysql_query($query)){
       die("error: ".mysql_error());
   }
     $i++;
  </code></pre>
  
  <p>What is causing the double quotes and how can I remove them when inserting the rows?  I have also tried <code>stripslashes</code> on the <strong>VALUES</strong> part of the query but it causes an error due to fields that have single quotes, double quotes, or other delimiters.  </p>