Jump to content

Array var not passing itself on


a1amattyj

Recommended Posts

Really odd, thanks in advance!

 

	
while($row = $db->fetch_array($query))
{
	if($row['clan'] > 0)
	{
		$query2 = $db->query(__FILE__,__LINE__,"SELECT * FROM `".DB_PREFIX."clans` WHERE `id` = '".$row['clan']."'");

		if($db->num_rows($query2))
		{
			$clDa = $db->fetch_array($query2);

			$row['clanname'] = $clDa['name'];
		}
	}	

	if(isset($row['clanname']))
	{
		echo "EXISTS<br />";
	}
	else
	{
		echo "nothing wrong with that..<br />";
	}

	if(isset($town[$row['town']]))
	{
		$row['city'] = $town[$row['town']];  
	}

	$assign[] = $row; 
	if(!isset($assign['clanname']))
	{
		echo "should show the name right here..<br />";
	}
	else
	{
		echo "brilliant<br />";
	}

 

outputs:

 

EXISTS

should show the name right here..

nothing wrong with that..

should show the name right here..

EXISTS

should show the name right here..

EXISTS

should show the name right here..

EXISTS

should show the name right here..

nothing wrong with that..

should show the name right here..

nothing wrong with that..

should show the name right here..

Link to comment
https://forums.phpfreaks.com/topic/193107-array-var-not-passing-itself-on/
Share on other sites

$assign[] = $row; // assign $row to $assign's next index, NOT to $assign itself.
if(!isset($assign['clanname'])) // check the $assign array for an index called 'clanname' - you did NOT assign this in the line above

 

I think what you meant to do is:

 

$assign = $row; // assign $row to $assign
if(!isset($assign['clanname'])) // check the $assign array for an index called 'clanname' - you DID assign this in the line above

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.