User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 373,098 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,870 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 289 | Replies: 5
Reply
Join Date: Jul 2007
Posts: 94
Reputation: Designer_101 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
Designer_101 Designer_101 is offline Offline
Junior Poster in Training

Question HELP!!!

  #1  
Mar 21st, 2008
HI
CAN ANYONE SEE Y THIS IS ECHOING OUT TWICE THE AMOUNTS OF EACH FIELD IN MY DATABASE???

  1. <?php
  2. $count = 0;
  3. $data = array();
  4.  
  5. $query = "SELECT * FROM profile WHERE ID = '1' ";
  6. $result = MYSQL_QUERY($query);
  7. $line = mysql_fetch_array($result);
  8.  
  9. foreach ($line as $col_value) {
  10. $data[$count] = $col_value;
  11. echo $data[$count];
  12. $count++ ;
  13. };

MUCH APPRECIATED
Last edited by peter_budo : Mar 22nd, 2008 at 4:48 pm. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Posts: 86
Reputation: sagedavis is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
sagedavis sagedavis is offline Offline
Junior Poster in Training

Re: HELP!!!

  #2  
Mar 22nd, 2008
hmmm,
first off, I don't know why your code isn't throwing an error to begin with.
you have an extra ";" at the end there... once you end a function } you don't need to use a ;

I think your problem might be the $count++ but I can't be 100 p on that.
also put a . before the = in your foreach statement and I think that does what you are trying to do.
$query = "SELECT * FROM profile WHERE ID = '1' ";
$result = MYSQL_QUERY($query);
$line = mysql_fetch_array($result);

foreach ($line as $col_value) {
$data[$count] .= $col_value;
echo $data[$count];
}

Sage
Reply With Quote  
Join Date: Jul 2007
Posts: 94
Reputation: Designer_101 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
Designer_101 Designer_101 is offline Offline
Junior Poster in Training

Re: HELP!!!

  #3  
Mar 22nd, 2008
hey
thanks for the advise
but i tried using a different variable names and it worked perfectly, maybe a reserved word in php or something.

Yeh anyways much appreciated ;D

thanks
Reply With Quote  
Join Date: Nov 2007
Posts: 86
Reputation: sagedavis is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
sagedavis sagedavis is offline Offline
Junior Poster in Training

Re: HELP!!!

  #4  
Mar 22nd, 2008
oh, duh,
was it "count" that was the reserved word?
sage
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,024
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 227
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: HELP!!!

  #5  
Mar 23rd, 2008
count is not a reserved word AFAIK. hmmm..
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jul 2007
Posts: 94
Reputation: Designer_101 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
Designer_101 Designer_101 is offline Offline
Junior Poster in Training

Re: HELP!!!

  #6  
Mar 23rd, 2008
intresting ?
Anyway

like i said thanks
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 4:58 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC