What is the difference between mysql_fetch_object and
mysql_fetch_array?

Answer Posted / ghan shyam

mysql_fetch_object : will return the results from database
as objects. fields will be accessible like in objects
i.e $result->name,$result->cust_name

mysql_fetch_array : will return the results from database as
array.
you have to define array type in second parameter of mysql_fetch_array function.

fields will be accessible like
$result[name],$result[cust_name] (if type =MYSQL_ASSOC)

or like
$result[0],$result[1] (if type =MYSQL_NUM)

or like
$result[name],$result[cust_name],$result[0],$result[1] (if type=MYSQL_BOTH)

Is This Answer Correct ?    6 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we set session value in javascript?

527


Tell me how can I display text with a php script?

520


Why do we need session?

543


In PHP, fgets() is used to read a file one line at a time. State Whether True or False?

585


Explain difference between urlencode and urldecode?

560






How easy is php?

526


Does session expire on closing browser?

493


What is difference between session and cookies in php?

476


How long does a php session last for?

569


How can you pass a variable by reference?

559


What is crypt () in php?

494


What are the delimiters in php?

526


Is php closing tag necessary?

559


How many data types are used by php?

515


How to get no. of rows using MYSQL function?

567