simona_85 Posted August 16, 2009 Share Posted August 16, 2009 For my final work, I need to do online shop over web services. The thing that I can't do is to show values from database when I return them with array. I have found some code over the internet but it return empty array. Can somebody help me? My code in web service is: require_once('C:\wamp\www\seminarskiIteh\lib\nusoap.php'); $connect = mysql_connect("localhost", "root", "") or die ("Neuspesna konekcija sa bazom podataka"); mysql_select_db("seminarski"); $server = new soap_server(); $server -> configureWSDL('webservis', 'urn:webservis'); $server->wsdl->addComplexType( 'Proizvod', 'complexType', 'struct', 'all', '', array( 'ID' => array('name'=>'ID','type'=>'xsd:int'), 'naziv' => array('name'=>'naziv','type'=>'xsd:string'), 'opis' => array('name'=>'opis','type'=>'xsd:string'), 'cena' => array('name'=>'cena','type'=>'xsd:float'), 'kolicina' => array('name'=>'kolicina','type'=>'xsd:int') ) ); $server->wsdl->addComplexType( 'NizProizvoda', 'complexType', 'array', '', 'SOAP-ENC:Array', array(), array( array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Proizvod[]') ), 'tns:Proizvod' ); $server->register('izmeniProizvode', array(), array('return' => 'tns:NizProizvoda'), 'urn:izmeniProizvode' ); I just wrote that function izmeniProizvode because the others works... function izmeniProizvode(){ $query="SELECT ID,naziv FROM proizvod WHERE kategorija='sofe' "; $result=mysql_query($query) or die(mysql_error()); $kolona=mysql_num_rows($result); if ($kolona>0){ while ($row = mysql_fetch_array($result)) { $niz[]=array('ID'=>$row['ID'], 'naziv'=>$row['naziv'] ); } } return $niz; } Link to comment https://forums.phpfreaks.com/topic/170500-problems-with-web-services/ Share on other sites More sharing options...
DEVILofDARKNESS Posted August 16, 2009 Share Posted August 16, 2009 Please use code-tags! Link to comment https://forums.phpfreaks.com/topic/170500-problems-with-web-services/#findComment-899397 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.