Am I using mysql_fetch_assoc and mysql_fetch_array the corre
Moderator: General Moderators
Am I using mysql_fetch_assoc and mysql_fetch_array the corre
When I usually call something from a database, I am either dealing with one record exclusivity or a whole bunch of record. I always use mysql_fetch_assoc when dealing with single record returns e.g. username-password authentication but if i want to display who is online for example, I just run a while ($user = mysql_fetch_array($rb_response)). Is this the correct approach?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Am I using mysql_fetch_assoc and mysql_fetch_array the c
It doesn't matter, it depends on how you want to fetch the array. fetch_assoc fetches only an associative array and fetch_array can fetch either a numerical or associative or by default both. I tend to always use mysql_fetch_assoc() or the mysqli functions.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.