Loading Array problems

Hi all,

I am some what perplexed at an issue I am having regarding the loading of an array which recieves the MySQL output. I am happy that the query works (tested direct in MYSQL).

However, only some of the variables actually seem to be passed from $result2 into $details

		$sql2 = 'select property.id, jobref, House_name, house_number, addline1, addline2, property.town, property.county, property.postcode, property.fee, 
		client.company, client.department, client.add1, client.add2, client.town, client.county, client.postcode
		from property inner join client on client.name = property.client where property.id = '.$id.' ';
		$result2 = mysqli_query ($link, $sql2);
		if (!$result2)
			$error = 'Error - Please enter a valid ID. ' . mysqli_error($link);
			include 'error.html.php';
		if ($result2<>'')
			while ($row = mysqli_fetch_array ($result2))
				$details[] = array (
				'property.id' => $row['id'],
				'House_name' => $row['House_name'],
				'house_number' => $row['house_number'],
				'addline1' => $row['addline1'],
				'addline2' => $row['addline2'],
				'property.town' => $row['town'],
				'property.county' => $row['county'],
				'property.postcode' => $row['postcode'],
				'property.fee' => $row['fee'],
				'client.company' => $row['client.company'],
				'client.department' => $row['client.department'],
				'client.add1' => $row['client.add1'],
				'client.add2' => $row['client.add2'],
				'client.town' => $row['client.town'],
				'client.county' => $row['client.county'],
				'client.postcode' => $row['client.postcode'] );
		echo '<pre>';
		echo '</pre>'; 

		include 'invoice.html.php';

property.id and others are showing as beign populated with the results however other fields, such as company.client and company.department are remaining empty.

I can not see the difference between those which work and those which fail, and would apprecaite any help that can be offered.

Many thanks in advance.

The column names in the array don’t contain the table name, so for example client.company is called company. A problem are for example property.town and client.town. Rename at least one of them in the query using an alias (client.town AS clienttown), otherwise who knows how the column will be called in the result set.

To know what your row contains, you can do a print_r($row)

Perfect - I removed the client.'s from $row section and it worked perfectly, looking back i dont know why i did that in the first place!!

Many thanks guido, very much appreciated.

In order to avoid so many assignments, you can just use

$details[] = $row;

in your while statement.