Arrays 使用远程计算机上会话中存储的阵列
我在会话中存储了一个数组,并将其发送到远程服务器上的一个函数。我正在使用这些值放入远程数据库。我的问题是数组正在发送,但它是空的 被发送Arrays 使用远程计算机上会话中存储的阵列,arrays,session,Arrays,Session,我在会话中存储了一个数组,并将其发送到远程服务器上的一个函数。我正在使用这些值放入远程数据库。我的问题是数组正在发送,但它是空的 被发送 <?php session_start(); require_once('lib/nusoap.php'); $blah = $_SESSION['blah']; $client = new nusoap_client( 'http://myserver.com/datatest.php' ); $response = $client->
<?php
session_start();
require_once('lib/nusoap.php');
$blah = $_SESSION['blah'];
$client = new nusoap_client( 'http://myserver.com/datatest.php' );
$response = $client->call('myfunction', $blah);
?>
在远程服务器上:
<?php
require_once('lib/nusoap.php');
$server = new soap_server();
$server->register('myfunction');
function myfuction ($blah)
{
//MY DB CONNECTIONS
$row = $blah;
$count = count($row);
for($i=0;$i<=$count-1;$i++){
$value1 = '8';
$item = $i+1;
$first = $row[$i]['first'];
$second = $row[$i]['second'];
$time = date("His");
$month = date("m");
$day = date("d");
$year = date("y");
$julian = juliantojd($month, $day, $year);
$sql = "INSERT INTO `MYTABLE` (value1, item, first, second, time, julian) VALUES ('$value1', '$item', '$first', '$second', '$time', '$julian')";
return $code_showing_query;
}
}
?>
好的,我发现了问题。。。事情很简单
对服务器上函数的调用:
$response = $client->call('myfunction', $blah);
应该是这样的:
$response = $client->call('myfunction', Array($blah));
我发送了一个多维数组,我发现服务器要查找的数组是一个基本数组,如下所示:
Array ( [something] => 5555 [something] => 5555 [something] => 5555)
但我发的是:
Array ( [0] => Array ( [something] => 5555 [something] => 5555 [something] => 5555 ) )
Array ( [0] => Array ( [something] => 5555 [something] => 5555 [something] => 5555 ) )
服务器看到:
Array ( [0] => Array // it ignored the rest of the array
更改后,$response=$client->call('myfunction',Array($blah))代码>
服务器现在正在查找:
Array ( [0] => Array ( [something] => 5555 [something] => 5555 [something] => 5555 ) )