SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot doca's Avatar
    Join Date
    Dec 2004
    Location
    Vienna, AT
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Warning: Invalid argument supplied for foreach() in ?? Help

    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

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,161
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    put var_dump($cron_ip, $cron_port); before your foreach and give us the output.

  3. #3
    SitePoint Zealot doca's Avatar
    Join Date
    Dec 2004
    Location
    Vienna, AT
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
    array(22) { [1]=> string(13) "78.129.199.49" [2]=> string(13) "78.129.199.49" [3]=> string(13) "78.129.199.49" [4]=> string(12) "67.15.73.219" [5]=> string(12) "67.15.73.219" [7]=> string(13) "85.25.100.218" [9]=> string(22) "streaming.tdiradio.com" [28]=> string(22) "free.freeshoutcast.com" [30]=> string(12) "77.105.36.58" [31]=> string(13) "212.72.100.23" [34]=> string(12) "91.121.52.62" [37]=> string(12) "media017.net" [39]=> string(12) "91.121.52.62" [104]=> string(22) "desetka.exyustream.com" [106]=> string(21) "streaming.radiojat.rs" [119]=> string(23) "streaming8.tdiradio.com" [127]=> string(17) "radioas.kbcnet.rs" [128]=> string(12) "217.24.17.31" [130]=> string(17) "live4.okradio.net" [153]=> string(13) "rtvpancevo.rs" [173]=> string(14) "87.106.136.203" [177]=> string(15) "213.239.205.210" } array(22) { [1]=> string(5) "12100" [2]=> string(5) "12200" [3]=> string(5) "12300" [4]=> string(5) "16000" [5]=> string(5) "30000" [7]=> string(5) "10200" [9]=> string(4) "9090" [28]=> string(5) "60026" [30]=> string(4) "8879" [31]=> string(4) "8400" [34]=> string(4) "8184" [37]=> string(4) "8034" [39]=> string(4) "8016" [104]=> string(2) "80" [106]=> string(5) "12121" [119]=> string(5) "13131" [127]=> string(4) "8020" [128]=> string(4) "8102" [130]=> string(4) "8052" [153]=> string(4) "7777" [173]=> string(4) "9400" [177]=> string(4) "6052" }

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,161
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    based on that, I'm not sure why you are receiving a warning about the foreach statement. You definitely have a valid array. Did you get a warning with the above var_dump()?

  5. #5
    SitePoint Zealot doca's Avatar
    Join Date
    Dec 2004
    Location
    Vienna, AT
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no that make me crazy

  6. #6
    SitePoint Zealot doca's Avatar
    Join Date
    Dec 2004
    Location
    Vienna, AT
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you cpradio
    you are right i have found some header errors.
    website works great now! thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •