Hi I have a table full of company names, the problem I am having is that it is full of duplicates.

To resolve this I am using the following piece of code to remove the data from one table and then insert it in to another using DISTINCT.

When i run the code, i keep getting the following error, 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Group Holdings Ltd')' at line 4

If i remove the company name variable it inserts all of the ip address fine, but as soon as i try to insert a company name i get the above error.

```
  $query = "SELECT DISTINCT ip_address, company_name, FROM companydetail1";      
  $result = mysql_query($query) or die(mysql_error());
  while($row = mysql_fetch_array($result)){

  $ip_address = $row['ip_address'];
  $company_name = $row['company_name'] ;
  mysql_real_escape_string($company_name);
  mysql_real_escape_string($ip_address);

  mysql_query("INSERT INTO companydetail30 (ip_address, company_name) VALUES ('$ip_address', '$company_name') ") or die(mysql_error());
   }

```

Any suggestions would be appreciated.

Thanks