hi,everyone it is a very strange problem,At first,i put my code into the method inner,it works.see below: ******************* start $str = "SQL HERE"; if (1 == 1) { $array = preg_split("~[^\"],~", $body); for ($index1 = 0; $index1 < count($motoCols); $index1++) { $tmp = ""; for ($index = 0; $index < count($array); $index++) { //取出每个JSON块 if ($index == count($array) - 1) { $tempStr = $array[$index]; } else { $tempStr = $array[$index] . "}"; } //转换成JSON 对象 $json = json_decode($tempStr); //过滤掉数据库中的非法字段 if (!in_array($json->key, $motoCols)) { continue; } if ($json->key == $motoCols[$index1]) { $tmp = $json->val; if ($index == 10 || $index == 12 || $json->key == "DeviceRepairCount") { $tmp .= ","; } else { $tmp = "'" . $tmp . "',"; } break; } else { if ($json->key == "DeviceRepairCount") { $tmp = "0,"; } else { $tmp = "'0',"; } } } $str .= $tmp; } $str = substr($str, 0, -1) . ",LAST_INSERT_ID())"; } $mysqli->query($str); ************************** end and,when i move this process-code into a separate function,and invoke it.it failed.see below: ********************** start function processJSONtoSQL($s,$b) { $array = preg_split("~[^\"],~", $b); for ($index1 = 0; $index1 < count($motoCols); $index1++) { $tmp = ""; for ($index = 0; $index < count($array); $index++) { //取出每个JSON块 if ($index == count($array) - 1) { $tempStr = $array[$index]; } else { $tempStr = $array[$index] . "}"; } //转换成JSON 对象 $json = json_decode($tempStr); //过滤掉数据库中的非法字段 if (!in_array($json->key, $motoCols)) { continue; } if ($json->key == $motoCols[$index1]) { $tmp = $json->val; if ($index == 10 || $index == 12 || $json->key == "DeviceRepairCount") { $tmp .= ","; } else { $tmp = "'" . $tmp . "',"; } break; } else { if ($json->key == "DeviceRepairCount") { $tmp = "0,"; } else { $tmp = "'0',"; } } } $s .= $tmp; } return substr($s, 0, -1); } invoke part: $str = "SQL HERE"; $str = processJSONtoSQL($str, $body) . ",LAST_INSERT_ID())"; $mysqli->query($str); *************************** end As you can see,it seems to be impossible.Can someone tell me WHY? -- Best regards, Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED**) Using Gmail? Please read this important notice: http://www.fsf.org/campaigns/jstrap/gmail?10073. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php