[Phpwm] nuSoap question
Phil Beynon
phil at infolinkelectronics.co.uk
Thu Oct 5 11:12:08 BST 2006
> <?php
> function getStockQuote($id) {
>
> mysql_connect('host','username','password');
> mysql_select_db('db');
> $query = "SELECT * FROM table "
> . "WHERE id = '$id' ";
> $result = mysql_query($query);
>
> while ($row = mysql_fetch_assoc($result)){
> return $row['stock'];
> }
> }
Thats not going to work. Its starting a loop then dropping straight out of
it with a return, it doesnt go anywhere else.
It should be 'return array' as well.
Plus if it didn't get a result and returned with no data wouldn't that
effectively unset() your variable when it returned with nothing?
> What I am trying to do is retrieve all stocks associated with the
> id that is
> entered in the form on the soap client. But it is only returning
> the first
> record in the table.
>
> If I try just the following SQL statement in a php file, it return all
> records:
>
> Code:
>
> mysql_connect('host','username','password');
> mysql_select_db('db');
> $query = "SELECT * FROM table "
> . "WHERE id = '$id' ";
> $result = mysql_query($query);
>
> while ($row = mysql_fetch_assoc($result)){
> echo $row['stock'];
> }
>
That works because the While loop gets a chance to finish, i.e. its parsed
the entire array.
Put PHPMyAdim on the server. It works! :-)
Regards,
Phil
More information about the Phpwm
mailing list