在PHP变量中使用更新字符串时,在MySQL中单个引号

时间:2017-04-07 08:06:14

标签: php mysql

我正在尝试使用LOAD DATA LOCAL FILE将一些数据导入MySQL时替换单引号... 这是我在PHP中的查询

$sql = "LOAD DATA LOCAL INFILE 'uploaded_files/uploaded.csv'
        INTO TABLE results
        FIELDS TERMINATED BY ','
        OPTIONALLY ENCLOSED BY '\"' 
        LINES TERMINATED BY '\\r\\n'
        IGNORE 1 LINES
        (Place, RaceNumber, Time, Firstname, Surname, Category,
         FirstInGroup, Notes, AdditionalNotes, club, Fullname)
        SET randomCode = '" .$random_code. "',
        distance = '" .$_POST["distance"]."',
        location = '" .$_POST["location"]."',
        DistanceName = '" .$_POST["distanceName"]."',
        intYear = '" .$_POST["intYear"]."',
        RaceDate = '" .$_POST["raceDate"]."',
        Race = '" .$_POST["race"]."',
        event = '" .$_POST["event"]."',
        raceID = '" .$_POST["raceID"]."',
        Time = replace(Time,'.',':'),
        Fullname = replace(Fullname,''','''');
        ";

我的问题是Fullname = replace(Fullname,''','''');不起作用,我需要替换'with''但它已经在一个字符串中,该行应该怎么样?

0 个答案:

没有答案