wright67uk Posted September 6, 2011 Share Posted September 6, 2011 Would both of the below snippets do the same job, if so why are both ways taught in text books, can one method do somthing that the other cannot? mysql_fetch_array($result, MYSQL_ASSOC)) And... mysql_fetch_assoc($result) Link to comment https://forums.phpfreaks.com/topic/246572-mysql_fetch_assoc-v-mysql_assoc/ Share on other sites More sharing options...
WebStyles Posted September 6, 2011 Share Posted September 6, 2011 mysql_fetch_array allows you to fetch a numeric array, an associative one or both at the same time. mysql_fetch_assoc only fetches the associative one. Your example will produce the same result. According to the manual on php.net mysql_fetch_assoc was only introduced in php 4.0.3, but it makes things easier to fetch associative results (most commonly used, less typing involved now) EDIT: quote from the manual: mysql_fetch_assoc() is equivalent to calling mysql_fetch_array() with MYSQL_ASSOC for the optional second parameter Link to comment https://forums.phpfreaks.com/topic/246572-mysql_fetch_assoc-v-mysql_assoc/#findComment-1266171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.