0) { $row_1=mysql_fetch_array($result_1); $query = "SELECT *, ABS(pos_X-".$row_1['pos_X'].") + ABS(pos_Y-".$row_1['pos_Y'].") dif FROM cities WHERE pos_X is NOT NULL AND pos_Y is NOT NULL AND NOT name='".$city_name."' AND `population` > '".$row_1['population']."' AND `valid`!='0' ORDER BY dif ASC LIMIT 0,5"; $result = mysql_query ( $query ) or die ( "Error while selecting " ); // mysql_error() if (mysql_num_rows($result)>0) { while ($row=mysql_fetch_array($result)) { $dist = distance($row_1['pos_X'], $row_1['pos_Y'], $row['pos_X'], $row['pos_Y']); if($dist<=$rast) $city_list[] = array("name" => $row['name'],'latname' => $row['latname'], 'kod_kov' => $row['kod_kov'],'rod' => $row['rod'],'dat' => $row['dat'],'vin' => $row['vin'],'tvor' => $row['tvor'],'pov' => $row['pov'],'dif' => $row['dif'],'population' => $row['population']); //$city_list[] = array("name" => $row['name'],'latname' => $row['latname'], 'kod_kov' => $row['kod_kov'],'rod' => $row['rod'],'dat' => $row['dat'],'vin' => $row['vin'],'tvor' => $row['tvor'],'pov' => $row['pov'],'dif' => $row['dif'],'population' => $row['population']); } } } return $city_list; } function bliz_goroda_url($mas, $uri) { $max=0; if($mas) { foreach($mas as $str2) { if($str2['population'] > $max) $max = $str2['population']; } } if($mas) { foreach($mas as $str) { if($str['population']==$max) $city_list .= ''.$str['name'].', '; else $city_list .= ''.$str['name'].', '; } } $city_list = substr($city_list, 0, -2); return $city_list; } ?>Can't connect to mySQL server