Hello

Why am I getting a PHP Warning: Invalid argument supplied for foreach()



Code PHP:
 
$sql="select id,ip,port from rtv where country='$cron_id' and active='1' order by id";
	$result = mysql_query($sql) or die("MYSQL ERROR: $sql");
	$numrows = mysql_num_rows($result);
	for($x=0;$x<$numrows;$x++){
	$resrow = mysql_fetch_row($result);
	$id = $resrow[0];
	$cron_rip = $resrow[1];
	$cron_rport = $resrow[2];
 
	$authid[$id] = $id;
	$cron_ip[$id] = $cron_rip;
	$cron_port[$id] = $cron_rport; 
 
}
 
foreach($cron_ip as $i => $servers)
	{
	$fp = @fsockopen($cron_ip[$i],$cron_port[$i],$errno,$errstr,4);
	if (!$fp) 
		{ 
		$listeners[$i] = "0";
		$msg[$i] = "server offline";   # ERROR [Connection refused / Server down]
		$error[$i] = "1";
		/* SERVER OFFLINE */
		$sql = "update rtv set info='0|0|0|0|offline', pozicija='0' where id='$authid[$i]'";
		$result = mysql_query($sql) or die("ERROR: $sql");
		} 
	else