Can somebody help me get an associative array returned via a webservice? Seems to me it should be simple but it’s not happening ïŒ
Basically I have a function:
function getInfo($user_name){
$connection = mysql_connect("localhost","root","");
$db = mysql_select_db("testdb",$connection);
$query_result = mysql_query("select * from tbl_user where user_name='$user_name'");
$row = mysql_fetch_array($query_result,MYSQL_ASSOC);
return $row;
}
So $row returned is an associative array.
I want to be able to use it like:
echo '<input name="full_name" type="text" id="full_name" value="' .$arr["full_name "] .'" size="60">'; etc.
ie. I know the name of the fields/columns – I want to be able to extract them easily as above.
The thing is, once this is a web service, things get a little weird and it’s down to me not knowing enough about WSDL and using types (I’m assuming at least!)
I sort of hacked the WSDL together from stuff I found on the web. This is the bits that matter:
<message name='getInfoResponse'>
<part name='Result' type='impl:ArrayOf_xsd_string'/>
</message>
And
<complexType name="ArrayOf_xsd_string">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
</restriction>
</complexContent>
</complexType>
It’s this line that gets me:
type='impl:ArrayOf_xsd_string'/>
With it in, the WSDL is NOT valid – but I get the associative array back just as I want. However, though it works with php/html, other clients (eg. Flash) die due to the 'impl:bit. If I remove that or replace it with
type='tns:ArrayOf_xsd_string'/> (and it becomes valid),
then instead of an associative array, I get a normal one, with numbered index. So I can’t go
.$arr["user_name "]
But have to go
.$arr[0]
instead – which isn’t handy for me.
So basically – can someone let me know what I am meant to do to simply get the associative array back from the webservice?
Thanks a lot,
M.