如何正确编写同时爆炸和mysql_real_escape_string的MySQL查询的代码?

这是我拥有的代码,但是失败了:

$sql = "INSERT INTO BEER_LOCATIONS
        (LOCATION_NAME, LOCATION_STREET, LOCATION_CITY, LOCATION_STATE,
        LOCATION_ZIPCODE, LOCATION_PHONE, BEER_STYLE )
    VALUES
        ('" . mysql_real_escape_string(implode("', '", $row)) . "')";


谢谢

最佳答案

implode("', '", array_map('mysql_real_escape_string', $row))


这会将mysql_real_escape_string应用于$row中的每个元素,并将包含转义值的数组返回到implode

10-06 02:40