• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

php: please review... can't find error..

Techies--
No errors, but nothing shows up on the page. I've been looking at it too long to identify the error--please review.  All this code is trying to do is return simple string values from a remote web service.

<?php

if ($_POST['zipn'] != ''){
  $zipn = (string) $_POST['zipn'];
  $client = new SoapClient("http://www.webservicex.net/medicareSupplier.asmx?WSDL");
  $result = $client->GetSupplierByZipCode(array('izipn' = $zipn));
  // Note that $array contains the result of the traversed object structure
  $array = $result->GetSupplierByZipCodeResult->tSupplierData;

  print "
<table border='2'>
  <tr>
    <th>SupplierNumber</th>
    <th>CompanyName</th>
    <th>Address1</th>
    <th>Address2</th>
    <th>City</th>
    <th>State</th>
    <th>Zip</th>
    <th>ZipPlus4</th>
    <th>Telephone</th>
    <th>IsSupplierParticipating</th>
  </tr>
";

  foreach($array as $k=>$v){
    print "
      <tr>
        <td align='right'>" . ($k+1) . "</td>
          <td>" . $v->sSupplierNumber . "</td>
		      <td align='right'>" . $v->sCompanyName . "</td>
		      <td align='right'>" . $v->sAddress1 . "</td>
		      <td align='right'>" . $v->sAddress2 . "</td>
		      <td align='right'>" . $v->sCity     . "</td>
		      <td align='right'>" . $v->sState    . "</td>
		      <td align='right'>" . $v->sZip      . "</td>
		      <td align='right'>" . $v->sZipPlus4 . "</td>
		      <td align='right'>" . $v->sTelephone . "</td>
		      <td align='right'>" . $v->sIsSupplierParticipating . "</td>
	  </tr>";

}

print "</table>";
}
else {

?>

<form id="Medicare Suppliers" action="index.php" method="post">
Which zip code are you interested in researching? (Type in a 5 digit zip code).
<input id="zipn" name="zipn" size="5" type="text" value="06512" />
<input id="submit" name="submit" type="submit" value="submit" />
</form>

<?php

}

?>

Open in new window

0
Paula DiTallo
Asked:
Paula DiTallo
  • 4
  • 2
1 Solution
 
gplanaCommented:
This is what I do when this happens to me:

try to comment all of your code and add an echo command at the end. Something like:

<?php
/*

all your php code here

*/
echo 'Hi!';
?>

you will see the message "Hi!" on the screen.

Then try to uncomment line by line until you found the error.

Another solution is to set the display mode to show errors, but some servers doesn't allow this, so on this case I use the technique I described above about commenting/uncommenting code.

Hope it helps.
0
 
Marco GasiFreelancerCommented:
Your line 6 is

$result = $client->GetSupplierByZipCode(array('izipn' = $zipn));

but should be

$result = $client->GetSupplierByZipCode(array('izipn' => $zipn));

=> instead of =

Cheers
0
 
Marco GasiFreelancerCommented:
I see also a bad value for form id which should not  contain white spaces: you should modify it to "MedicareSuppliers"

Cheers
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Paula DiTalloIntegration developerAuthor Commented:
@margusG -- great catches!

  $result = $client->GetSupplierByZipCode(array('izipn' => $zipn));  

I think this is the line where things go wrong, now that you spotted it-- the other method i was working with was by supplier id--which was convenient since i had an integer to work with while cycling thru an array...

What is the best way to work with this array of strings (zip codes) that look like numbers?
0
 
Marco GasiFreelancerCommented:
Php is smart enough to understand by itself is a value is a string or a number, so you can be happy leaving Php does the work for you.

That said, your question (what is the best way...) is too vague for me. If you need more help, you should post an example of the array you need to process and say exactly what you want to get. In addition, I don't have any idea about what GetSupplierByZipCode() method does. AFAIK, your code should work fine once you fix the error mentioned above :)

Cheers
0
 
Paula DiTalloIntegration developerAuthor Commented:
Thanks margus--I come from the c# world -- i would have had to have create a integer/string-key pair to cycle through the array.
0
 
Marco GasiFreelancerCommented:
Thanks for points and good luck with your project.

Marco
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now