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

Explain about objects in PHP?

578


What kind of variable is age?

607


What is the difference between echo print and print_r in php?

520


Where is session value stored?

561


How can you upload a file using php?

553






What is Type hinting in PHP?

716


Is python better than php?

507


What is basename php?

519


am from coimbatore.am learning php&mysql. what will be the approx salary for me if i get a job in coimbatore.

1557


Is php easier than node?

521


What is PHP's configuration file called?

569


What is the purpose of pear in php?

587


What is mvc? Why its been used?

513


Explain about the data types in PHP?

556


What is php default argument?

542