Page 1 of 1

[SOLVED] - Arrays in Arrays from Queries

Posted: Sat Aug 14, 2004 10:22 pm
by anjanesh
I have an array $arrMain[] which contains a mysql_fetch_assoc() array.
I've also added other fields from different queries.

Code: Select all

$PhotosRow=mysq_fetch_assoc(....);
$arrMain['Photo'][$i]=$PhotosRow // its in a loop
But this gives Notice: Array to string conversion in xxx\xxx.php on line xxx

Code: Select all

$PhotosRow is say Array([ID]=>5,[Data]=>xxx)
I thought I could get $arrMain['Photo'][$i]['ID'] and $arrMain['Photo'][$i]['Data'] but instead Im getting $arrMain['Photo'][$i]="A" (The first letter in Array (....))
Anyone know how to resolve this ?
Thanks

Posted: Sat Aug 14, 2004 10:24 pm
by d3ad1ysp0rk
are you sure PhotosRow is an actual array?

Posted: Sat Aug 14, 2004 10:29 pm
by anjanesh
If $PhotosRow weren't an array it wouldn't show the Notice: Array to string conversion - would it ?
This is actual code and output :

Code: Select all

$PhotosRow=mysql_fetch_assoc($PhotosRes);
$arrInputFields['Photo'][$i]=$PhotosRow;
print_r($PhotosRow);
Notice: Array to string conversion in xxx on line xxx
Array ( [HouseID] => 3 [ImageURL] => HouseID3kitchen 1.jpg [View] => Kitchen [Words] => Kitchen with microwave oven, cupboards etc [Viewed] => 0 )

Posted: Sat Aug 14, 2004 11:14 pm
by anjanesh
Solved. My mistake.
There was already an index Photo in arrMain so reassigning to an array wasn't seemed to be possible. I changed the new index to Photogallery and it worked