Hi
I am trying to make a jukebox using MySQL. When a user clicks on artist name, aritst ID is passed to another php script that opens a database and look for songs for that ID. Then it creates a web page with all those songs listed and with a check box in front of each song. When user select songs from that list and click the play button, an array is passed to another script which contains song_ID of each selected song. This script then opens the database that contains the URL for that song ID. Upto this ppoint everything works very well. But when I try to play the song using header function, it generates and error as follow:
Warning: Cannot add header information - headers already sent by (output started at /www/songs/play.php:1) in /www/songs/play.php on line 14
This error is generated for every song ID
Any idea where I am doing wrong??
The source code for the script that play songs is given below;
<?
$numrow=count($song_list);
$i=0;
$connection=mysql_connect("localhost","songviewer","viewer") or die ("Couldn't connect to server.");
$db=mysql_select_db("songs",$connection) or die ("Couldn't open the database.");
$sql="SELECT * FROM main";
$sql_result=mysql_query($sql,$connection) or die ("Couldn't execute query");
while ($row=mysql_fetch_array($sql_result))
{
$id=$row["ID"];
$link=$row["URL"];
if ($id == $song_list[$i])
{
$url_go="Location: http://217.15.5.97" . $link;
header("$url_go");
$i++;
}
}
mysql_free_result($sql_result);
mysql_close($connection);
?>