Ask a question MySQL Recordset does not support the MoveNext method?

Source: Internet
Author: User
Tags tagname
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?
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.