我有这段代码
$con = mysqli_connect(**);
$con2 = mysqli_connect(**);
$sta = mysqli_query($con2, "SELECT a, b FROM c WHERE a LIKE '%t%' AND d > '0' ");
while ($row = mysqli_fetch_array($sta, MYSQLI_ASSOC)) {
$na = $row['a'];
$arr = explode("-", $na, 2);
$cb = $arr[0];
$intemp = mysqli_query($con, "SELECT * FROM o WHERE c = '$arr[0]' AND k = '$arr[1]' ");
$num_rows = mysqli_num_rows($intemp);
if (!$num_rows > 0) {
mysqli_query($con, "INSERT INTO o *works*");
// *********
$RSTCI = $arr[1];
if ($RSTCI != '') $pars .= '<ns1:c>' . $RSTCI . '</ns1:c>';
$RSTIT = $row['stat_user'];
if ($RSTIT != '') $pars .= '<ns1:i>' . $RSTIT . '</ns1:i>';
$act = 'rST';
$ns1 = 'rSTR';
$user = $row['user'];
$loc = '**';
$url = '**';
$soap_data = '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="**"><env:Header><ns1:Action>/' . $act . '</ns1:Action><ns1:c>' . $arr[0] . '</ns1:c>' .
'</env:Header><env:Body><ns1:' . $ns1 . '>' . $pars . '</ns1:' . $ns1 . '></env:Body></env:Envelope>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: /" . $act,
"Content-length: " . strlen($soap_data),
);
$url = $loc;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSLCERT, "**");
curl_setopt($ch, CURLOPT_CAINFO, "**");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $soap_data); // the SOAP request
$response = curl_exec($ch);
$foo = str_replace('<', '<', str_replace('>', '>', $soap_data));
$respfoo = str_replace('<', '<', str_replace('>', '>', $response));
mysqli_query($con, "INSERT INTO *works*");
mysqli_query($con, "INSERT INTO *works*");
$wait = curl_init("**");
curl_setopt($wait, CURLOPT_RETURNTRANSFER, 1);
curl_exec($wait);
curl_close($wait);
// *********
}
}
&GT;
我知道由于删除敏感信息,这可能更难理解。会发生什么是mysqli_query $ sta返回3个左右的结果。以下&#39; while&#39;应该循环3x(返回的行数),直到我在// *********之间添加SOAP和cURL行。 当我删除所有这些行时,来自查询$ sta的信息被插入到数据库$ con中就好了3x
mysqli_query($con, "INSERT INTO o *works*");
所以我知道这有效。
什么可能导致脚本只在运行SOAP请求时运行一次?测试之间没有其他任何变化。此外,SOAP请求工作得很好并且在循环(3)中发送,或者作为脚本单独发送,没有错误。我的目标是重复SOAP请求,但是很多时候$ sta中有行,因为每个SOAP请求的数据都会根据这些行中的数据而变化。