2
Contributors
2
Replies
6
Views
5 Years
Discussion Span
Last Post by nikki05
1

Likely to be a problem with SQL rather than reading the csv.
You may need to use mysql_real_escape_string() on data items - you could use array_map for this. I'm assuming you have a variation on the following:

     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
     {
         //this line added
         $data = array_map("mysql_real_escape_string",$data);

         $sql = "INSERT into users(name,lastname,email) values('$data[0]','$data[1]','$data[2]')";
         mysql_query($sql) or die(mysql_error());
     }
0

Hi Diafol,
Thank you very much for your code. It helped me to solve my problem.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.