Correct Syntax

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Correct Syntax

Post by PastorHank »

Would someone please tell me the correct syntax to use to determine which row of a resultset I am working on?
The result set is returned with

Code: Select all

while ($row = mysql_fetch_array($result)) {
  extract($row);
I know the array starts at row[0] but for the life of me, none of my if statements seem to work.


Thank you
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Because it can't create variable names that are numbers, try the EXTR_PREFIX_INVALID flag for extract().
(#10850)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

or use mysql_fetch_array($result, MYSQL_ASSOC)
and/or do not extract the elements but use the array like e.g. echo $row['fieldname'];
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Post by PastorHank »

Thank you. After enough beating my head against the wall, I simply used a counter set to zero and incremented it after use....it was very much a 'duh' moment.
Post Reply