在下面的查询中,我使用str_replace函数去掉'"''从我解析的一些数据。我收到了这个错误。关于如何解决这个问题的任何想法?请注意,第24行具有str_replace功能
Fatal error: Only variables can be passed by reference in /public_html/Offices/update_db.php on line 24
查询:
$i = 0;
while (($data = fgetcsv($handle, 0, $separator)) !== FALSE) {
if ($i == $first_row_offset) {
$fields = [];
foreach ($data as $key => $item) {
$fields[$item] = $key;
}
} elseif ($i > $first_row_offset) {
$query = 'SELECT * FROM offices_empty_locations WHERE address="' . str_replace('"', '\"',$data[$fields['addres']], 0, 250)) . '" AND zip="' . $data[$fields['zip']] . '"';
$result = mysqli_query($mysqli, $query);
while ($tmp_data = mysqli_fetch_assoc($result)) {
if (isset($tmp_data['latitude']) && $tmp_data['latitude'] > 0) {
$query = 'UPDATE offices_main SET field_value="' . $data[$fields['lat']] . '" WHERE id=' . $tmp_data['latitude'] . ' AND field_value=""';
mysqli_query($mysqli, $query);
}
if (isset($tmp_data['longitude']) && $tmp_data['longitude'] > 0) {
$query = 'UPDATE offices_main SET field_value="' . $data[$fields['lon']] . '" WHERE id=' . $tmp_data['longitude'] . ' AND field_value=""';
mysqli_query($mysqli, $query);
}
}
}
$i++;
}
答案 0 :(得分:0)
http://php.net/manual/en/function.str-replace.php
str_replace('"', '\"',$data[$fields['addres']], 0, 250))
error ┘ │ │
what? ┘ │
nooo ┘