scotchegg78 Posted June 12, 2008 Share Posted June 12, 2008 Hi guys. My code works fine locally just not on the live server. When i run the sql qry on the live server in mysql admin it also works fine!? Anway its not getting the last row regionID, but its getting everything else? row regionName etc.. $sql = "SELECT * FROM cr_region LEFT JOIN cr_office USING (regionID) ORDER BY cr_region.regionID"; $result = $dblink->query($sql); $lastid = ''; while($row = $result->fetch_assoc()){ if($lastid != $row['regionID']){ $array[$row['regionID']] = array('regionID'=>$row['regionID'],'regionName'=>$row['regionName'],'address1'=>$row['regionaddress1'],'address2'=>$row['regionaddress2'],'address3'=>$row['regionaddress3'],'address4'=>$row['regionaddress4'],'town'=>$row['regiontown'],'county'=>$row['regioncounty'],'country'=>$row['regioncountry'],'postcode'=>$row['regionpostcode'],'webaddress'=>$row['webaddress'],'regionEmail'=>$row['regionEmail'],'regionTelephone'=>$row['regionTelephone'],'message'=>$row['message']); $lastid = $row['regionID']; } echo $row['regionID']; if(!is_null($row['officeID'])){ $array[$row['regionID']]['offices'][] = array('address1'=>$row['address1'],'address2'=>$row['address2'],'address3'=>$row['address3'],'address4'=>$row['address4'],'town'=>$row['town'],'county'=>$row['county'],'country'=>$row['country'],'postcode'=>$row['postcode']); } } Whats going on!? only thing is we are on mysql 5 local and mysql 4 live? So again, It gets everything else except for the last region ID from the last row? but the qry in admin seems fine, when I also print the array its all there except the last $row[regionID]? Any ideas? Quote Link to comment Share on other sites More sharing options...
scotchegg78 Posted June 12, 2008 Author Share Posted June 12, 2008 ok ok, I have noticed the mysql admin run has two regionID columns, one from my region table and one from my office table. So its allowing ambiguity?! i guess i have to address them via row direct not assoc. Quote Link to comment Share on other sites More sharing options...
fenway Posted June 12, 2008 Share Posted June 12, 2008 ok ok, I have noticed the mysql admin run has two regionID columns, one from my region table and one from my office table. So its allowing ambiguity?! i guess i have to address them via row direct not assoc. No, you have to alias them, or don't use *. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.