943,949 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 769
  • PHP RSS
Mar 21st, 2008
0

HELP!!!

Expand Post »
HI
CAN ANYONE SEE Y THIS IS ECHOING OUT TWICE THE AMOUNTS OF EACH FIELD IN MY DATABASE???

PHP Syntax (Toggle Plain Text)
  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 5:48 pm. Reason: Keep It Organized - please use [code] tags
Reputation Points: 12
Solved Threads: 16
Posting Whiz
Designer_101 is offline Offline
314 posts
since Jul 2007
Mar 22nd, 2008
0

Re: HELP!!!

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.
PHP Syntax (Toggle Plain Text)
  1. $query = "SELECT * FROM profile WHERE ID = '1' ";
  2. $result = MYSQL_QUERY($query);
  3. $line = mysql_fetch_array($result);
  4.  
  5. foreach ($line as $col_value) {
  6. $data[$count] .= $col_value;
  7. echo $data[$count];
  8. }

Sage
Reputation Points: 10
Solved Threads: 6
Junior Poster in Training
sagedavis is offline Offline
86 posts
since Nov 2007
Mar 22nd, 2008
0

Re: HELP!!!

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
Reputation Points: 12
Solved Threads: 16
Posting Whiz
Designer_101 is offline Offline
314 posts
since Jul 2007
Mar 22nd, 2008
0

Re: HELP!!!

oh, duh,
was it "count" that was the reserved word?
sage
Reputation Points: 10
Solved Threads: 6
Junior Poster in Training
sagedavis is offline Offline
86 posts
since Nov 2007
Mar 23rd, 2008
0

Re: HELP!!!

count is not a reserved word AFAIK. hmmm..
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Mar 23rd, 2008
0

Re: HELP!!!

intresting ?
Anyway

like i said thanks
Reputation Points: 12
Solved Threads: 16
Posting Whiz
Designer_101 is offline Offline
314 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: adding name 2login
Next Thread in PHP Forum Timeline: PHP-MySQL connection error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC