Lost the \ character when parsing csv?

There is a csv file where some fields contain the \character.
This file is parsed by php and the received data are entered in the MySQL table.
include 'connect.php';
 $table = "".$prefix."table"; 
 $handle = fopen('php://memory', 'w+');
fwrite($handle, iconv('CP1251', 'UTF-8', file_get_contents('in.csv')));
 $r = 0; 
while (($row = fgetcsv($handle, 1000, ';', '"')) != FALSE) 
 if($r == 1) {continue;} // does Not write to the database the first row 
 $ins="INSERT INTO $table (`1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`) VALUES ('$row[0]', '$row[1]', '$row[2]', '$row[3]', '$row[4]', '$row[5]', '$row[6]', '$row[9]')";
 if (mysql_errno()) {echo mysql_errno() . '\n' . mysql_error() . '\n';}

After the skid data into a table missing \ characters (the characters / are left untouched).
How with these to struggle? Thanks in advance!

Solved the problem thanks ILoveYAnny:

change Msql request
$ins=sprintf("INSERT INTO $table (`1`, `2`, `3`, `4`, `5`, `6`, `7`) VALUES ('$row[0]', '$row[1]', '$row[2]', '$row[3]', '%s', '$row[5]', '$row[6]')",mysql_real_escape_string($row[4]));

(in my case the problem was in $row[4])
September 19th 19 at 13:01
1 answer
September 19th 19 at 13:03
I may be wrong, but I think PHP takes it as a escape character. Try to specify the shielding before \ , perhaps there are other ways to indicate that it is not a symbol ekranirovaniya, and character text. MB to indicate quotation marks.
I think so too. But the problem is that this file is formed not by me, and the changes in its structure during the formation make can't. Contains nearly 40 thousand rows, so manually screened to zaklopatica can!!!How to force php not to perceive this character as an escape character? - reagan_Christiansen58 commented on September 19th 19 at 13:06
: Exit in my opinion, is to find or write a parser swio without a shield, or copy 40 thousand rows (if you have access to the source code) in Notepad++ to find a pattern and replace)

In General, I think the Internet is already an implementation of parser that treats the backslash as a character.

Here are a couple of articles www.sql.ru/forum/797838/kak-sohranit-soderzhimoe-x...


And here are a couple of functions php.net/manual/ru/ref.strings.php . They feel it is possible to use third party parser. Or somewhere for the text to catch and handle. In General, all depends on tasks.

stripcslashes — Removes escaping characters produced by the function addcslashes
stripslashes — Remove the escaping characters - Shawna_Hegma commented on September 19th 19 at 13:09
Thank you!Your response helped! He described the decision in question. - reagan_Christiansen58 commented on September 19th 19 at 13:12
: Glad that helped :) - Shawna_Hegma commented on September 19th 19 at 13:15

Find more questions by tags PHPCSVMySQL