Thanks for the reply but these leave me with a problem. The following query is what is echoed and it obviously does not insert into the database:
INSERT INTO mytable (field1, field2, field3, field4)
VALUES ('text2\',\'text2\',\'text3\',\'text4\r\n')
I tried changing it to addslashes but this still causes the problem. Is ther any way I can just escape any chars in one field, for example 'field4'?
for ($i=1; $i<sizeof($filecontents); $i++)
{
$line = trim($filecontents[$i], ',');
$arr = explode(",", $line);
$q= "INSERT INTO mytable (field1, field2, field3, field4) VALUES ('". implode("','", $arr) ."')";
mysql_query($q);
}
Many thanks for your help.