473,499 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

difference between mysql_fetch_assoc and mysql_fetch_array

sanjay123456
125 New Member
Dear friends ,


Plz any one tell me What is difference between mysql_fetch_assoc and mysql_fetch_array while both are return associtive array ?
Oct 25 '07 #1
3 11354
jx2
228 New Member
Dear friends ,


Plz any one tell me What is difference between mysql_fetch_assoc and mysql_fetch_array while both are return associtive array ?
mysql_fetch_array will return twice as much data!! and doesnt work well if you use foreach();
simply try it for each of them!!
[php]
foreach($yourArray as $k =>$v){
echo "$k => $v <br>";
}
[/php]

jx2
Oct 25 '07 #2
Lumpy
69 New Member
Straight from the php website...

mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both

mysql_fetch_assoc — Fetch a result row as an associative array

I think what this is saying is that mysql_fetch_array can be used like...
Expand|Select|Wrap|Line Numbers
  1. $row['fieldname'] 
  2. or
  3. $row[0]
  4.  
where mysql_fetch_assoc can only be used like...
Expand|Select|Wrap|Line Numbers
  1. $row['fieldname']
  2.  
hope this helps.
Oct 25 '07 #3
tolkienarda
316 Contributor
mysql fetch array function allows for two inputs the first is the result reasource, this is the only required field but you can enter what kind of array you would like, the default is MYSQL_BOTH which means it works as either kind of array or you can tell it to only use numbers or associative keys, the mysql fetch assoc function is the same as mysql fetch array with the MYSQL_ASSOC option.

http://us2.php.net/manual/en/function.mysql-fetch-array.php
http://us2.php.net/mysql_fetch_assoc

the manual for php is very useful and easy to read


eric bressler
Oct 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

15
2648
by: Good Man | last post by:
Hey there I have a dumb question.... Let's say i have a database full of 4000 people.... I select everything from the database by: $result = mysql_query("SELECT * FROM People");
4
2940
by: Marcel Brekelmans | last post by:
Hello, I seem to get an extra empty field in every 'mysql_fetch_array' command I issue. For example: I have a simple table 'tblName': ID Name 1 Jane 2 Joe 2 Doe
3
4612
by: Paul Lautman | last post by:
Are there any benefits to using mysql_fetch_object() instead of mysql_fetch_assoc()?
9
7401
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
3
5344
by: smythe70 | last post by:
How do mysql_query() and mysql_fetch_assoc() actually work? When I submit a query to a MySQL database it goes away, works out what I requested and throws it back at me. When I submit a query...
2
2351
by: phattymatty | last post by:
I am having trouble getting this loop to do what I would like it to. I need to display information from a multidimensional array in order. The order has already been sorted in the array using a...
5
2716
by: clodhoppers18 | last post by:
I am trying to get the following code to work, and I am having some problems: The code goes for actually 110 lines, but I have dismissed what is not needed. The connection and all that works for...
1
1757
by: bytesFTW99 | last post by:
Ok I have a problem! i have a mysql_fetch_assoc that does not recognize the NULL value of the column. however, i want this null to be picked up so i can use it. how can i go about doing that? ...
2
16964
by: poreko | last post by:
I am connecting to my database using Object oriented PHP. My query is returning results but at the end of my table,at the bottom of the page I keep having this error when I run my program: Warning:...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.