Error not displaying

Onefunsossy

New Member
I have this xml format:\[code\]<searches> <search><name> stephen </name><address> box 23 </address><sector> IT </sector><contacts>+233247764939 </contacts><search><name> stephen </name><address> box 23 </address><sector> IT </sector><contacts>+233247764939 </contacts><searches>\[/code\]When the value for the name node is not found I will like to display the error to the user.I have tried using the code below but it seems the echo statement is not executing hence when the name node value is empty or does not contain a value an empty screen shows without the echo message. Any help with this code?NB: if the name has no value then it means the company does not exist. this code returns a value to $objj to the next php script.Below is the complete code:\[code\]<?php function processing($term){$params = array ('username' => 'username', 'password' => 'password', 'term'=> $term); // Build Http query using params$query = http_build_query ($params);// Create Http context details$contextData = http://stackoverflow.com/questions/11384895/array ('method' => 'POST','header' => "Connection: close\r\n"."Content-Type: application/x-www-form-urlencoded\r\n"."Content-Length: ".strlen($query)."\r\n",'content'=> $query );// Create context resource for our request$context = stream_context_create (array ( 'http' => $contextData ));print_r($context);// Read page rendered as result of your POST request$result = file_get_contents ('http://infolinetest.nandiclient.com/search/searches/requestData.xml', // page urlfalse,$context);// Server response is now stored in $result variable so you can process it$obj = @simplexml_load_string($result); return $obj } ?>//the outputting is done in this script<?php $objj = processing ($term); ?><div data-role="listview"><ul data-role="listview" data-theme="g" data-inset="true" class="ui-listview ui- listview-inset ui-corner-all ui-shadow"><a href="" data-role="button" data-theme="g" data-inset="true"><strong>Search Results</strong></a><?php if ($objj){ ?> <?php foreach(@$objj as $searches):?><li> <a href="http://stackoverflow.com/questions/11384895/Result_Selected.php?company=<?php echo $searches -> name.'<br/>'.$searches->sector.'<br/>'.$searches ->address.'<br/>'.$searches -> contacts.'<br/>'; ?>" data-role="button"><?php echo( $searches -> name).'<br/>'.$searches - > sector ?></a></li><?php endforeach ?><a data-ajax="false" href="http://stackoverflow.com/questions/11384895/#top" data-role="button" name= "smt"><strong>End Of List... </strong></a><?php } else if(empty($objj)||($objj==null)||($objj->name=="")){ ?><?php echo "hello company not found.try again"; } ?></ul>\[/code\]
 
Back
Top