Always displays the false value?

[php]<?php

$sc_url_ip = “xx.xxx.xx.xxx”;
$sc_url_port = “8063”;

function getNowPlaying($sc_url_ip,$sc_url_port)
{

$open = fsockopen($sc_url_ip,$sc_url_port,$errno,$errstr,’.5’);
if ($open) {
fputs($open,“GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n”);
stream_set_timeout($open,‘1’);
$read = fread($open,200);
$text = explode(",",$read);
if($text[6] == ‘’ || $text[6] == ‘’){ $msg = ’ live stream '; } else { $msg = $text[6]; }
$text = $msg;
} else { return false; }
fclose($open);

return $text;	

}

$csong = getNowPlaying($sc_url_ip,$sc_url_port);
print ‘’.$csong.’’;
print “
”;

if ($csong == “Song Title Here”)
print “True”;
else
print “False”;
?>
[/php]

Basically pulls the song title from a shoutcast server. Trying to use this information to tell what DJ is playing (song wont change based on what DJ is playing) so… if it matches the song playing, then a certain DJ is playing, hence the if statement. But, this code always returns the false value? I am still not that good with php but I do believe it has to do with the way my $csong variable is set? Any help would be great! Thanks a lot! The code works, just not the if statement with the $csong variable.

all i did was delete the

print “false”; line just above the last ?>

this:
[php]if ($csong == “Song Title Here”)
print “True”;
else
print “False”;[/php]

should be:

[php]if ($csong == “Song Title Here”) {
print “True”;
}
else {
print “False”;
}[/php]

even if you can use php without brackets, its better to anyways.

Now that I look it over more, your opening a socket, not grabbing data. you need to grab data from that port/ip then do the work on it

try:

[php]$open = file_get_contents($sc_url_ip . ‘:’ . $sc_url_port);[/php]

i have a php shoutcast currently playing script in a iframe how do i get the iframe to refresh without refreshing the whole page

Sponsor our Newsletter | Privacy Policy | Terms of Service