What is the difference between mysql_fetch_object and
mysql_fetch_array?

Answer Posted / rupal

mysql_fetch_row ::Return row as aan enumrated array and each
line contain a unique ID .example.
$result=mysql_query($query);
while($row=mysql_fetch_row($result))
{
print $row[0] ;
print $row[1] ;
print $row[2] ;
}

mysql_fetch_array ::Return row as anassociative or an
enumrated array or both which is default .you can refer to
outputs as databases fieldname rather then number .example.
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
print $row['name'] ;
print $row['address'] ;
print $row['city'] ;
}

mysql_fetch_object :: it return as an object on the place of
array.

$result=mysql_query($query);
while($row=mysql_fetch_object($result))
{
print $row->name ;
print $row->address ;
print $row->city ;
}

Is This Answer Correct ?    18 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you pass an array into a function?

556


What is a php namespace?

517


What is the difference between laravel and php?

498


Explain what is the function file_get_contents() usefull for?

504


What is the use of post in php?

502






What is meant by urlencode and urldecode?

602


What are different types of runtime errors in php?

547


What is in a cookie?

547


What is the differences between $a != $B and $a !== $B?

530


What is namespace in php?

549


What type of operation is needed when passing values through a form or an url?

524


What is the importance of parser in php?

606


What are different types of Print Functions available in PHP?

526


How to retrieve the original query string?

565


Which function is used in php to check the data type of any variable?

516