Title: Can I upload CSV file to MySQL database without deleting "\" backslash which is placed in CSV file using php
Tags: php;mysql;backslash;fgetcsv
Question: Csv file has been uploaded to database but backslash() is automatically getting deleted when I upload CSV file to database.
I need that \ to be also uploaded in the database.
For eg : I need to add the folder location into database like C:\Users\Others\Desktop\Gips report but it shows like C:UsersOthersDesktopGips report

``` $filename=$_FILES["file"]["tmp_name"];
    if($_FILES["file"]["size"] &gt; 0)
    {

        $file = fopen($filename, "r");

        while (($emapData = fgetcsv($file, 10000, ",", '"' , '"' )) !== FALSE)

  {

            $sql = "INSERT INTO csvfile(id,Projectnumber,Projectfolder,e0id) VALUES ('".$emapData[0]."','".$emapData[1]."','".$emapData[2]."','".$emapData[3]."')";
            if (mysqli_query($conn, $sql)) {
  echo "New record created successfully";
} else {
  echo "Error: " . $sql . "<br&gt;" . mysqli_error($conn);
}
        }
        fclose($file);
        echo "CSV File has been successfully Imported";
        }
    else
        echo 'Invalid File:Please Upload CSV File';
}
```

Comment: Use prepared statements. Then there is no need to escape anything.

Comment: Welcome to Stack Overflow. It's almost impossible for us to help you unless you show us a bit of code, or at least explain how you read your .csv file and INSERT its rows to your table. And, please show us a few lines of your file, including some with the `\\` characters you want preserved in your table.  Please [edit] your question or ask another.

Comment: Of course you can. Prepared statements and parameters don't prevent you from doing that

Comment: hi Jones i have edited and added a bit of code

Comment: Hi markus but iam using array to import all the datas in file to database so if i use prepared statement then i cannot fetch all datas from csv file to database right?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 5, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:05/10/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<php><mysql><backslash><fgetcsv>', 'Title': 'Can I upload CSV file to MySQL database without deleting "\\" backslash which is placed in CSV file using php', 'ViewCount': 51, 'id': 61711852, 'user_AboutMe': None, 'user_AccountId': 14181512.0, 'user_DisplayName': 'Sabari', 'user_Reputation': 1.0, 'user_Views': 6.0, 'user_id': 10244923.0}}