2013-07-05 48 views
0

我在一個會話中存儲了一個數組,我正在發送到遠程服務器上的一個函數。我正在使用這些值來放入遠程數據庫。我的問題是陣列正在發送,但它是空的。在遠程計算機上使用存儲在會話中的數組

發送

<?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; 

} 
} 
?> 

當我執行這一點,我在服務器上設置的可變因素(項,值1等)插入到數據庫,但我發送的第一個和第二個是emtpy。

我可以返回我發送的$ blah數組,並返回值。當然會話仍然在我的瀏覽器中,但我失去了它去遠程服務器。我曾嘗試以下內容:(肯定它不是去上班,但我試過)

<?php 
$blah = $_SESSION['blah']; 
$blah = serialize($blah); 
$blah = base64_encode($blah); 

//AT THE REMOTE SERVER 
$blah = base64_decode($blah); 
$blah = unserialize($blah); 
?> 

基本上,我需要找到除了愛情之外,以找到除了愛情之外,使陣列我從會話失控的我會話發送到遠程服務器,因此它不會關聯到會話。在此之前,我必須保留所有內容,因爲這是一個訂購系統,我必須將最終訂單發佈到遠程iSeries。

我知道這是一些簡單的...只是我還沒有做過和/或它只是絆倒methanks任何幫助

回答

0

好吧,我發現這個問題......這是簡單的東西。

到服務器上的函數調用:

$response = $client->call('myfunction', $blah); 

應該是這樣的:

$response = $client->call('myfunction', Array($blah)); 

我發送multidiminsional陣列,和我的服務器一直在尋找陣列是一個基本陣列看起來像這樣:

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))