Difference Between mysql_fetch_array,mysql_fetch_row in php

Dear friends i m explaining with example

Many of the php programmer getting confused about mysql_fetch_array(),mysql_fetch_row(), mysql_fetch_assoc() and mysql_fetch_object() functions but all these functions result getting same.  let me explain in detail

Create table “smitcky” with three fields i.e id,username and password

1

 

create database_connection.php

mysql_fetch_row()

  • it fetch a result row as an numeric array.

Output Result

1 smitcky smitcky@123

mysql_fetch_array()

  • it fetch a result row as an associate array and a numeric array and combine of both i.e numeric as well as associate array.

output Result:

1 smitcky smitcky@123

mysql_fetch_object()

  • this function fetch a result row as an object. let me explain with example.

Output Result:

1 smitcky smitcky@123

mysql_fetch_assoc()

  • this function fetch a result row as an associate array.let me explain with example in below code.

Output Result:

1 smitcky smitcky@123

Run above all the code in your system and i hope you now get difference between all the mysql_fetch_array,mysql_fetch_row,mysql_fetch_object and mysql_fetch_assoc. this all functions name is difference but it give same result as you sawn in above all the example. only difference is calling row array is different way.