Mar*_*ark 2 php mysql-real-escape-string implode
如何正确编写内爆和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)) . "')";
Run Code Online (Sandbox Code Playgroud)
谢谢
dec*_*eze 11
implode("', '", array_map('mysql_real_escape_string', $row))
Run Code Online (Sandbox Code Playgroud)
这适用mysql_real_escape_string于每个元素$row并返回一个带有转义值的数组implode.