How we differentiate between mysql_fetch_object and mysql_fetch_array?

3 replies
I m learning PHP and MYSQL, any body knows about this, tell me, thanks in advance.
#differentiate #mysqlfetcharray #mysqlfetchobject
  • Profile picture of the author Justin Hedge
    They're essentially the same. The only difference being that one returns an array, and another an object. Indirectly, that means when using the object variant you can only access the data by field names (and not offsets).
    {{ DiscussionBoard.errors[3225335].message }}
    • Profile picture of the author Ambius
      on a related note, I often like to use mysql_fetch_assoc() so I can call values by their name instead of array position.
      {{ DiscussionBoard.errors[3226409].message }}
    • Profile picture of the author limcode
      Originally Posted by Justin Hedge View Post

      They're essentially the same. The only difference being that one returns an array, and another an object. Indirectly, that means when using the object variant you can only access the data by field names (and not offsets).
      You're right.
      {{ DiscussionBoard.errors[3227851].message }}

Trending Topics