/    Sign up×
Community /Pin to ProfileBookmark

while problem

Hello webdeveloper,

I have a php/nusoap script with the following problem:

The script works well accept one thing:

The function shows only one result on my screen. I know there are more items with those conditions. Here are the server and client script.

Client

[code=php]
<?php
error_reporting(E_ALL);
require_once(‘lib/nusoap.php’);

$wsdl=”http://localhost:80/stockserver.php?wsdl”;
$c = new nusoap_client(“http://localhost/stockserver.php?wsdl”, true);
$proxy = $c->getProxy();
$rows = $proxy->call(‘getStockQuote’, array(‘VVSUBGROEPA’ => ‘Rond’, ‘VVHOOFDGROEP’ => ‘RVS’));

echo “Item ‘RVS’ ‘Rond’ is $rows.”;

?>
[/code]

Server

[code=php]
<?php
error_reporting(E_ALL);
function getStockQuote($symbol) {

$prod_conn=odbc_connect(“Nfsupplies”,”test”,”test”,””);
if (!$prod_conn)
{
exit(“<font color=’#FF0000′>Can’t connect:</font> ” . $prod_conn);
}
$query = “select CDARTIKEL FROM ARTIKEL WHERE (VVSUBGROEPA Like ‘$symbol’) AND VVOPWEB = ‘Ja'”;

$result = odbc_exec($prod_conn, $query);

if (!$result)
{
exit(“<font color=’#FF0000′>error in sql:</font> ” . $result);
}

while ($row = odbc_fetch_array($result)){
return $row[‘CDARTIKEL’];
}
}

require(‘lib/nusoap.php’);

$server = new soap_server();

$server->configureWSDL(‘stockserver’, ‘urn:stockquote’);

$server->register(“getStockQuote”,
array(‘VVSUBGROEPA’ => ‘xsd:string’),
array(‘return’ => ‘xsd:string’),
‘urn:stockquote’,
‘urn:stockquote#getStockQuote’);
//$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ”;
//$server->service($HTTP_RAW_POST_DATA);
$server->service(file_get_contents (‘php://input’));
?>
[/code]

How can I get more items? If I add this(below) in server:

[code=php]
$aData = array();
while ( $row = odbc_fetch_array( $result ) )
{
$aData[] = $row[‘CDARTIKEL’];
}
return $aData;
[/code]

My output will be: Artikel ‘RVS’ ‘Rond’ is Array. instead of: Artikel ‘RVS’ ‘Rond’ is 673001001.

Can anyone help a desperate person? Thanx

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@Phill_PaffordAug 19.2008 — Looks like you tell it to return in the while loop

[code=php]
while ($row = odbc_fetch_array($result)){
return $row['CDARTIKEL']; //<-- Returns and stops the loop
}
[/code]


also you have this

[code=php]
$aData = array(); //<-- Don't need this, you make the array in the while loop, just an FYI
while ( $row = odbc_fetch_array( $result ) )
{
$aData[] = $row['CDARTIKEL'];
}
return $aData;
[/code]


Hope this helps
Copy linkTweet thisAlerts:
@Phill_PaffordAug 19.2008 — to use this you would need to loop through the array data

[code=php]
while ( $row = odbc_fetch_array( $result ) )
{
$aData[] = $row['CDARTIKEL'];
}
return $aData;

foreach($aData as $k => $d)
{
echo "Key: " . $k . " DATA: " . $d . "<br />";
// Might need to do another foreach loop on the $d as well, nested foreach

foreach($d as $k2 => $d2)
{
echo "Key2: " . $k2 . " DATA2: " . $d2 . "<br />";
}
}
[/code]
Copy linkTweet thisAlerts:
@damen18authorAug 19.2008 — Thank you so much for your reply. I'm still getting the same output on my screen.

Artikel 'RVS' 'Rond' is Array.

Array has to be the value.

Maybe the code in client is incorrect. But i really don't know what the problem is....
×

Success!

Help @damen18 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...