954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

HELP!!!

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

<?php
$count = 0;
$data = array();

$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];
		   $count++ ;
};


MUCH APPRECIATED

Designer_101
Posting Whiz
314 posts since Jul 2007
Reputation Points: 12
Solved Threads: 16
 

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

sagedavis
Junior Poster in Training
86 posts since Nov 2007
Reputation Points: 10
Solved Threads: 6
 

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

Designer_101
Posting Whiz
314 posts since Jul 2007
Reputation Points: 12
Solved Threads: 16
 

oh, duh,
was it "count" that was the reserved word?
sage

sagedavis
Junior Poster in Training
86 posts since Nov 2007
Reputation Points: 10
Solved Threads: 6
 

count is not a reserved word AFAIK. hmmm..

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

intresting ?
Anyway

like i said thanks

Designer_101
Posting Whiz
314 posts since Jul 2007
Reputation Points: 12
Solved Threads: 16
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You