Hey, I was wondering why my code wasn't working? What I'm doing is its downloading data from the server, then it's parsing it (removing the first line) and then updating all channel data that does not match the new data inside MySQL, and displays it as well for Yahoo! Widgets parsing. Here is my code...
var MyStreams = new Array(<?php
//get data & remove first line
$dat = file_get_contents("http://207.210.102.183/tracker.txt?".time());
$dat = explode("\n", $dat);
$data = array();
for($i=1; $i < count($dat); $i++) $data[$i] = $dat[$i];
//process code
mysql_connect("localhost","widget_source","*********");
mysql_select_db("widget_source");
$dat = join("\n", $data);
$lines = explode("\n---\n", $dat);
foreach($lines as $line) {
$d = explode("\n", $line);
$sql = mysql_query("SELECT * FROM data WHERE channel='$d[0]';");
$num = mysql_num_rows($sql);
$artist = $d[2]; $song = $d[3];
$da = mysql_fetch_array($sql);
if($artist != $da['artist'] && $song != $da['song']) {
mysql_query("UPDATE data SET artist='".$artist."', song='".$song."' WHERE channel='$d[0]';");
$content .= "new Array('$d[0]','$artist','$song',''),";
}
}
$content .= ");";
$content = str_replace("'),);","'));", $content);
echo $content;
?>