function GetTags ($device)
{
$sql = "Select TagName from TagList where device= ' $device '";
$rs = mysql_query ($sql);
while (! $rs->eof)//Save the Recordset to a two-dimensional array
{
$tags [] = Array (' tagname ' = = $rs->fields[' tagname ']->value);
$rs->movenext ();
}
return $tags;
Mysql_free_result ($RS); To close a data set
}
Why am I in PHP query MySQL database, operation record set using MoveNext method always error No-object? Does the MySQL recordset not support this method? Does the array $tags in the loop return correctly outside the loop?
I want to store the recordset into an array, and return this array, please look at the master!
Reply to discussion (solution)
Yes, not supported.
while ($row = Mysql_fetch_assoc ($rs)) //Save the Recordset to a two-dimensional array { $tags [] = $row;}
that return $tags;
Can this statement return a value?
Of course I can!
What problem are you having?
$tags have only one record, it's strange, if you query multiple fields, how do I save to a two-dimensional array? After storing the effect $tags (' tagname ', ' Device ', ' unit '), can $tags[$i][tagname] Such reference, this should save AH? MySQL this piece is not the same as Oracle, please help, thank you!
$sql = "Select Tagname,device,unit from TagList where device= ' $device '";
$rs = mysql_query ($sql);
.......
It's strange, after
while ($row = Mysql_fetch_assoc ($rs)) //Save the Recordset to a two-dimensional array { $tags [] = $row;}
After $tags is not a two-dimensional array?