tags:

views:

42

answers:

3
$result = mysql_query("SELECT * FROM users");
$values = array();
while($row = mysql_fetch_array($result)) 
{
$values[] = array($row['tried']);
}
return $values;

That only returns the word array when being called as a webservice. What am I missing or doing wrong?

+2  A: 

It's not returning the word 'array', it's telling you that what is being returned is an array.

To see what is in the array, use either var_dump($values); or print_r($values);. The only difference is the format of the display.

In addition, I don't believe you need to declare array in your assignment to $values.

$values[] = $row['tried'];

should work. $values will still be an array.

kevtrout
thanks for this worked perfectly...now just need to figure out this " content type of 'text/html', but expected 'text/xml'" error when it returns $values
Jon
A: 

I guess you can try changing the last line to: return json_encode($values);. It should at least let you see what you're doing (and may even be usable, depending on situation).

Pies
A: 

You don't have to SELECT * if you are only using one column. Just SELECT that column.

If it is printing out array, you are probably calling

echo $values;

This is not going to work. There are many solutions to see what you want, e.g.

foreach ($values as $val) { echo $val; }
tandu