/    Sign up×
Community /Pin to ProfileBookmark

fetch_row vs. fetch_array?

what’s the difference between (if MySQL) mysql_fetch_row() and mysql_fetch_array() functions ?

when to use this function and when to use the other?
thx

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 31.2007 — Pesonally, I almost always use mysql_fetch_assoc() (equivalent to mysql_fetch_array() with the [b]MYSQL_ASSOC[/b] 2nd argument), as it ensures that I don't run into problems by mis-counting which row element number to use; plus it helps the code to be more self-documenting by always referring to field names instead of result row field numbers.

About the only time I'll use mysql_fetch_row() is if I'm only retrieving a single column, in which case there is no ambiguity as to what field will be accessed by the fetch, and I can therefore safely take advantage of the (very slight) speed advantage.
Copy linkTweet thisAlerts:
@ShaReBauthorMar 31.2007 — Thanks NogDog and aj_nsc..
×

Success!

Help @ShaReB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...