Jump to content


Photo

Help..?


  • Please log in to reply
13 replies to this topic

#1 CAPTAINCAPSLOCK

CAPTAINCAPSLOCK
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 21 October 2006 - 01:18 AM

Well, a friend and I are trying to make a VDJ for our Counter-Strike:Source server. (Basically we want to put music on our site and link it to our server, so that people can listen to music while they're in the game.) When we try to go to www.KingsofSlaughter.com/vdj.php and click a song, it gives us an error. First the error was on line 7, then 9, then 13, and now it's on 9 again. I'm pretty sure the error is in the play.php. We're basically PHP newbs so I'm not sure if you guys could even help us but.. any ideas? Here are the PHP files.

Play.php:
<title>Virtual DJ</title>

<body bgcolor="#000000" link="#FFFFFF" vlink="#FFFFFF">

<font color="#FFFFFF" size="4">&nbsp;

<?php>

echo "<table border=0 width=350 align=left cellspacing=3>

<tr><td align=center colspan=2>

<a href="http://www.kingsofslaughter.com/vdj.php"><img src="http://www.kingsofslaughter.com/vdj-playing.jpg" border=0></a>;

</td></tr>

<tr><td align=right bgcolor=#222222><font color=#FFFFFF size=4>";

$string = $_SERVER['QUERY_STRING'];

$patterns[0] = '/%20/';

$patterns[1] = '/.mp3/';

$patterns[1] = '/.MP3/';

$replacements[0] = ' ';

$replacements[1] = ' ';

$replacements[2] = ' ';

$printname = preg_replace($patterns, $replacements, $string);

$letters = $printname;

$letters = explode(" - ",$letters);



echo ' Artist:</td><td bgcolor=#111111 align=center><font color="#FFFFFF" size=5><b>'.$letters[0].'</b></td></tr><tr><td align=right bgcolor=#222222><font color="#FFFFFF" size=4> Song Title:</td><td bgcolor="#111111" align=center><font color="#FFFFFF" size=5>'.$letters[1].'</font></tr></td>';

?>

<tr><td colspan=2>

<center>

<font size="2" color="#FFFFFF">(Allow 3-15 seconds for playback to begin. You may close this window at any time and it will not interupt playback)</font></center>

</td></tr><tr><td colspan=2>

<font size="4" color="#FFFFFF">

<br>

Type "<font color="red">STOP</font>" or <a href="stopped.php"><font color="red">Click Here</font></a> to stop playing at any time.

</font>

</td></tr></table>

<EMBED SRC=http://www.KingsofSlaughter.com/vdj/mp3/<?php echo $_SERVER['QUERY_STRING']; ?> AUTOSTART=true HIDDEN=true LOOP=0>



</pre>


Vdj.php:
<title>Virtual DJ</title>
<body bgcolor="#000000" link="#FFFFFF" vlink="#EEEEEE" alink="#FFFFFF" text="#FFFFFF">
<table width="400" border="0"><tr><td colspan="1" align="center">
<center><img src="http://kingsofslaughter.com/images/banner1.jpg">
<font color="#FFFFFF"> 
<?php
echo '';
echo "";
    if ($handle = opendir('./mp3/')) { // read the current directory. Change the "." to the directory you need.
    	$filecount = "0"; //reset the number of files
    while (false !== ($file = readdir($handle))) { 
    if ($file != "." && $file != "..") { // remove the move up directory commands. (. and ..)
    			$fileList[] = trim($file); // add the file to an array so it can be sorted easily.
    			$filecount = $filecount + 1; //count the number of files
    } 
    }
print '<font size="3" color="#FFFFFF">&nbsp;Songs:</font><font size="4" color="red"> <b>'.$filecount.'</b></font>'; //display the number of files
echo '</td></tr></table><table width="400" border="0">';
echo '
</td></tr>
<tr><td bgcolor="#222222"><font size="5" color="white"><b>Artist Name</b></font></td>
<td align="right" bgcolor="#222222"><font size="5" color="white"><b>Song Title</b></font></td></tr>';

    	sort ($fileList); // sort the file list in the array
    	reset ($fileList); // go back to the top of the array
    	while (list ($key, $val) = each ($fileList)) {
$namedisplay = $val;
$string = $namedisplay;
$patterns[0] = '/%20/';
$patterns[1] = '/.mp3/';
$patterns[2] = '/.MP3/';
$replacements[0] = ' ';
$replacements[1] = ' ';
$replacements[2] = ' ';
$printname = preg_replace($patterns, $replacements, $string);

$letters = $printname;
$letters = explode(" - ",$letters);
$recallme = $val;
echo '<tr><td bgcolor="#111111"><a href="http://KingsofSlaughter.com/vdj/play.php?'.$val.'"><b>'.$letters[0].'</b></a></td><td bgcolor="#111111" align=right>';
echo '<a href="http://KingsofSlaughter.com/vdj/play.php?'.$recallme.'">'.$letters[1].'</td></tr>';
    	}
    closedir($handle); 
    }

echo "</table>"
    ?>
</center>


#2 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 21 October 2006 - 01:23 AM

in play.php where you echo on line 9. .just change all double quotes " to single ' INSIDE of the echo statement.. thats the problem :)

#3 CAPTAINCAPSLOCK

CAPTAINCAPSLOCK
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 21 October 2006 - 01:37 AM

Forgive me for my idiocy, but line 9 would be..which one? DX

#4 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 21 October 2006 - 01:41 AM

lol change this:
echo "<table border=0 width=350 align=left cellspacing=3>

<tr><td align=center colspan=2>

<a href="http://www.kingsofslaughter.com/vdj.php"><img src="http://www.kingsofslaughter.com/vdj-playing.jpg" border=0></a>;

</td></tr>

<tr><td align=right bgcolor=#222222><font color=#FFFFFF size=4>";
to this:
echo "<table border=0 width=350 align=left cellspacing=3>

<tr><td align=center colspan=2>

<a href='http://www.kingsofslaughter.com/vdj.php'><img src='http://www.kingsofslaughter.com/vdj-playing.jpg' border='0'></a>

</td>

</tr>

<tr><td align=right bgcolor=#222222><font color=#FFFFFF size=4>";
that should do it

#5 CAPTAINCAPSLOCK

CAPTAINCAPSLOCK
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 21 October 2006 - 01:42 AM

Ok thank you very much.. I'll give it a try.

#6 CAPTAINCAPSLOCK

CAPTAINCAPSLOCK
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 21 October 2006 - 01:49 AM

Ok, I changed it to this and I still get that error on line 9 =\

<title>Virtual DJ</title>

<body bgcolor="#000000" link="#FFFFFF" vlink="#FFFFFF">

<font color="#FFFFFF" size="4">&nbsp;

<?php>

echo "<table border=0 width=350 align=left cellspacing=3>

<tr><td align=center colspan=2>

<a href='http://www.kingsofslaughter.com/vdj.php'><img src='http://www.kingsofslaughter.com/vdj-playing.jpg' border=0></a>;

</td></tr>

<tr><td align=right bgcolor=#222222><font color=#FFFFFF size=4>";

$string = $_SERVER['QUERY_STRING'];

$patterns[0] = '/%20/';

$patterns[1] = '/.mp3/';

$patterns[1] = '/.MP3/';

$replacements[0] = ' ';

$replacements[1] = ' ';

$replacements[2] = ' ';

$printname = preg_replace($patterns, $replacements, $string);

$letters = $printname;

$letters = explode(" - ",$letters);



echo ' Artist:</td><td bgcolor=#111111 align=center><font color="#FFFFFF" size=5><b>'.$letters[0].'</b></td></tr><tr><td align=right bgcolor=#222222><font color="#FFFFFF" size=4> Song Title:</td><td bgcolor="#111111" align=center><font color="#FFFFFF" size=5>'.$letters[1].'</font></tr></td>';

?>

<tr><td colspan=2>

<center>

<font size="2" color="#FFFFFF">(Allow 3-15 seconds for playback to begin. You may close this window at any time and it will not interupt playback)</font></center>

</td></tr><tr><td colspan=2>

<font size="4" color="#FFFFFF">

<br>

Type "<font color="red">STOP</font>" or <a href="stopped.php"><font color="red">Click Here</font></a> to stop playing at any time.

</font>

</td></tr></table>

<EMBED SRC=http://www.KingsofSlaughter.com/vdj/mp3/<?php echo $_SERVER['QUERY_STRING']; ?> AUTOSTART=true HIDDEN=true LOOP=0>



</pre>


#7 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 21 October 2006 - 01:57 AM

Exactly what error are you getting? I don't seem to see it posted anywhere.

#8 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 21 October 2006 - 01:58 AM

never seen this tag before:

<?php>


#9 CAPTAINCAPSLOCK

CAPTAINCAPSLOCK
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 21 October 2006 - 01:59 AM

Ok. Sorry, I should have done that heh. When I go to http://www.kingsofsl...ter.com/vdj.php and click on a song, it should either start playing or download, either way I'd know it's working. But I get this error..

Parse error: parse error, unexpected T_ECHO in /home/content/h/o/c/hockeylife/html/play.php on line 9

#10 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 21 October 2006 - 02:02 AM

^ I hope you know that akitchin was suggesting that <?php> isn't even a tag. Instead it should be:
<?php
code here
?>

Fix that and it should solve your current error.

#11 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 21 October 2006 - 02:04 AM

indeed that's what i was implying.  when you get a parse error, the usual tactic is to check the line in question first.  if there are no conceivable errors there, look up line by line.  bad coding on one line can cause a parse error on the line after by virtue of its ability to change the parsing flow.

an exception is if you get unexpected $end.  then you just make a mad search for unclose braces.

#12 CAPTAINCAPSLOCK

CAPTAINCAPSLOCK
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 21 October 2006 - 02:07 AM

TY!! It worked. Wow.. I tried 6 forums over the past week and this place gives me a reply within seconds lol. You guys are great, thanks again.






edit: Typogasm.

#13 kalivos

kalivos
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationCalifornia

Posted 21 October 2006 - 02:15 AM

FYI: change

$patterns[1] = '/.MP3/';

to

$patterns[2] = '/.MP3/';

in play.php
Make a donation to phpfreaks. They need your help![br][br]

#14 CAPTAINCAPSLOCK

CAPTAINCAPSLOCK
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 21 October 2006 - 05:30 AM

lol ty.. Btw, any suggestions on PHP tutorials?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users