Basically, Im trying to get a list of groups that a member is part of in an array (excluding a few), and limiting it to certain status in that group. I want all the values returned from the query to go into an array. The problem is, when I do...

$row = $ClubGDC(54);
echo $row[0];

...for example, it returns blank, and when printf-ing it, it is completely empty. So even though the SQL command DOES return values in a database query, this array is empty.

I have no idea if this is even the proper way to do what im trying to do. If someone could please help, it would be much appreciated. The full function is below:

function ClubGDC($userid)
{
	$gdcarray = array();
	$query = "SELECT * FROM members WHERE access < 300 AND status='Active'";
	$query .= "AND group!= 1 AND group!= 234 AND group!= 99999999999 AND group!= 199 AND group!= 228 ";
	$query .= "AND id = $userid";
	$q = mysql_query($query);
	$i2 = 0;
	while($row = mysql_fetch_array($q))
	{
		$gdcarray[0] = $row["group"];
		$i2++;
	}
	return $gdcarray;
	
}
while($row = mysql_fetch_array($q))
	{
		$gdcarray[] = $row["group"];
		$i2++;
	}

Try to replace while loop with above code.

The array is still empty. Maybe there is something wrong with my display code?

$gdcarray1 = ClubGDC(54);
print_r($gdcarray1);

Nevermind...the array isnt empty. Didnt upload properly.

Lets debug code.

<?
	function ClubGDC($userid)
	{
		$gdcarray = array();
		$query = "SELECT * FROM members WHERE access < 300 AND status='Active'";
		$query .= "AND group!= 1 AND group!= 234 AND group!= 99999999999 AND group!= 199 AND group!= 228 ";
		$query .= "AND id = $userid";
		$q = mysql_query($query);	
		echo '<br />Query:'.	$query;
		while($row = mysql_fetch_array($q))
		{
			$gdcarray[] = $row["group"];	
			echo '<br />group:'.$row["group"];		
		}
		return $gdcarray;		
	}
	
	$gdcarray1 = ClubGDC(54);
	//print_r($gdcarray1);
?>

Check this code and test if $query is returning proper output.
post your printed output.

Script works great now. Thank you very much.

Okay.. it is working? gr8.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.