.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> JavaScript/VBScript >> Post New QuestionBookmark and Share Subscribe to Forum

What is the difference between mysql_fetch_object and mysql_fetch_array in PHP?

Posted By: Jack Smith     Posted Date: September 19, 2012    Points:5   Category :JavaScript/VBScript
What is the difference between mysql_fetch_object and mysql_fetch_array in PHP? please Define in coding

Author: satyapriyanayak             
Posted Date: March 11, 2013     Points: 20   

Mysql_fetch_object returns the result from the database as objects while mysql_fetch_array returns result as an array. This will allow access to the data by the field names. E.g. using mysql_fetch_object field can be accessed as $result->name and using mysql_fetch_array field can be accessed as $result->[name]

1. mysql_fetch_row($result):- where $result is the result resource returned from a successful query executed using the mysql_query() function.

$result = mysql_query("SELECT * from students);
while($row = mysql_fetch_row($result))
Some statement;

2. mysql_fetch_array($result):- Return the current row with both associative and numeric indexes where each column can either be accessed by 0, 1, 2, etc., or the column name.

$row = mysql_fetch_array($result)

3. mysql_fetch_assoc($result): Return the current row as an associative array, where the name of each column is a key in the array.

$row = mysql_fetch_assoc($result)

If this post helps you mark it as answer

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend