Problem Passing variable

Hi.

I have a bit of code where I am having huge problems with passing a variable that has been retrieved from some XML. If I hardcode the variable it all works as expected. I have checked to see if I am getting the expected results from the xml and I am. I have implemented dumping everything to text files and checking the responses and it all looks to be correct but I just can’t seem to get this to work as it should. I am sure I am missing something small but what!

Here is some code - please note its just snippets of code…

[xml]
<?xml version=“1.0”?>
<NewOrder>
<Token>104EPU4dAJsOVjofEguhB5p6</Token>
</NewOrder>
[/xml]


if($res['NewOrder'] && ($token = $res['NewOrder'][0]['Token'][0])){
	file_put_contents($token.'.txt', trim(print_r($token,true)), FILE_APPEND);
	//token="104EPU4dAJsOVjofEguhB5p6"; //this works as expected....
        $order = $pl->get_order_info($token,"api");	
	//file_put_contents('orderResults.txt', trim(print_r($order,true)), FILE_APPEND);
	
    // Build vars array:
    $vars = array(
	'OrderID'	=>	$order['Response'][0]['OrderInfo'][0]['Id'][0],
	'Amount'	=>	$order['Response'][0]['OrderInfo'][0]['GrandTotal'][0],
	'Status'	=>	'payment',
	'AMemberID'	=>	'',
	'NextRebillDate'=>	''
    );
    $vars['PostbackPassword'] = $pl->config['postback_password'];
    $str = join('', array_values($vars));
    $md5 = md5($str);
    $vars['VerifySign'] = $md5;
    unset($vars['PostbackPassword']);
    $pl->handle_postback($vars);



}

    function get_order_info($order_id,$location)
		{
			file_put_contents('getOrderInfoTokenBefore'.$location.'.txt', trim(print_r($order_id,true)) . " " . time()."location: ".$location, FILE_APPEND);
        	        $order = $this->xml_parsexml($this->api_call("amemberOrder", $order_id));
			file_put_contents('getOrderInfoTokenAfter'.$location.'.txt', trim(print_r($order_id,true)) . " " . time()."location: ".$location, FILE_APPEND);
			file_put_contents('getOrderInfo.txt', trim(print_r($order,true)) . " " . time(), FILE_APPEND);
			return $order;
		}

There is a lot more code than this but that’s the bones of what is failing…

As said when I hardcode the variable it works 100% perfectly all of the time. if I use the processed XML it fails 100% of the time which makes me think I am doing something daft.

Thanks
Chris

All I can suggest is what I always suggest - keep echoing the variable surrounded by something until you can see it. I’m no expert but can’t see a specific issue with the code above, such as it is.

I’ve noticed that some XML parsers don’t include the “root” node. If you var_dump() $res is it there?

Sorry for the late reply

The problem was actually on the server I was receiving the xml from - basically the server sent a notification, my website then sent the curl requests back asking for information - the problems came about due to a race condition in that I was asking for the information before the information was available due to the way it was presented on the other server.

To solve the problem the developer of the other site changed the code to present the xml to me immediately and everything started to work just fine…

Thanks for the pointers though,
Chris