I am trying to make a project that will play a file by getting the name of the file from a database, and adding it to the end of a constant path. I am sending the name of the file with the URL to the playback page. I have the player embeded but i keep getting errors that seem to be related to the variable containing the path and the variable containing the file name....here's the code:

<html>
<body >
<script language="javascript">
    function playIt(){
    var Whos = "<?=$what?>";
    var WHAT = "C:\Documents and Settings\Player\";
	Player.URL = "WHAT" + "Whos" ;
	Player.controls.play();}
   function stop() { 
   mePlayer.controls.stop();}
</script>
<?php
   // get the id from the URL request
   $who = $_REQUEST['who'];                //example of who is beachtrip.asfv where 
   $long = strlen($who);                         //v indicates the table the video is from                
$Where = substr($who,$long-1);
$what = substr($who,0,$long-1);
?> <table width="100%" height="100%"> <tr> <td align="left" valign="bottom" colspan="2"> <form name="medForm" action=""> <input type="button" onclick="playIt()" value="PLAY">&nbsp <input type="button" onclick="stop()" value="STOP"> </form> </td> </tr> <tr> <td colspan="2" style="font-family:verdana;font-size:8pt;" align="center"> <OBJECT id='mePlayer' width="600" height="450" classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'> <param name="fileName" value=""> <param name="animationatStart" value="true"> <param name="transparentatStart" value="true"> <param name="autoStart" value="true"> <param name="showControls" value="true"> <param name="loop" value="false"> </OBJECT> </td> </tr> </table> </body> </html>

I am getting an unterminated string constant error when the page loads as well as object expected errors when play and stop are clicked.

I have no idea what I am doing wrong or where the error is at. I would be greatful for any help 😕

    When you load that page... what HTML/JavaScript is displayed?

      I'm sorry I'm not sure what you are asking. Are you asking what is on the screen? if so its the Play button, the Stop button & the controls for the media player.

        No, sorry, I meant when you load the page and go to View Source, what is the code that you see.

          oh!! Ok, this is what is shown...

          	<script language="javascript">
          function playIt(){
              var Whos = "<br />
          <b>Notice</b>:  Undefined variable:  what in <b>c:\easyphp1-8\www\pdisplay.php</b> on line <b>11</b><br />
          ";
          	var WHAT = "C:\Documents and Settings\Player\";
          	alert("WHAT" + "Whos");
          	mePlayer.URL = "WHAT" + "Whos" ;
          	mePlayer.controls.play();
          
          }
          
          function stop() { 
          mePlayer.controls.stop();
          			}
          </script>
          video01.asfs<br />12<br />s<br /video01.asf
          <table width="100%" height="100%">
          <tr>
          	<td align="left" valign="bottom" colspan="2">
          	<form name="medForm" action="">
          		<input type="button" onclick="playIt()" value="PLAY">&nbsp
          		<input type="button" onclick="stop()" value="STOP">
          	</form>
          	</td>
          </tr>
          <tr>
          	<td colspan="2" style="font-family:verdana;font-size:8pt;" align="center">
           	<OBJECT id='mePlayer' width="600" height="450"
          		classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
          codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
          		standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
          			<param name="fileName" value="">
          			<param name="animationatStart" value="true">
          			<param name="transparentatStart" value="true">
          			<param name="autoStart" value="true">
          			<param name="showControls" value="true">
          			<param name="loop" value="false">
          	</OBJECT>
          
          </td>
          </tr>
          </table>
          </body>
          </html>
          

            Here's your problem right here: 😃

            var Whos = "<br />
            <b>Notice</b>:  Undefined variable:  what in <b>c:\easyphp1-8\www\pdisplay.php</b> on line <b>11</b><br />
            ";

              I see it but I don't see what is causing it....when I echo each of the variables they print exactly the response I expect...and what is declared in line 17....

              $what = substr($who,0,$long-1);

              ???

                Oh sorry I missed something...

                <html>
                <body >
                <script language="javascript">
                    function playIt(){
                    var Whos = "<?=$what?>";
                    var WHAT = "C:\Documents and Settings\Player\";
                	Player.URL = "WHAT" + "Whos" ;
                	Player.controls.play();}
                   function stop() { 
                   mePlayer.controls.stop();}
                </script>
                <?php
                   // get the id from the URL request
                   $who = $_REQUEST['who'];                //example of who is beachtrip.asfv where 
                   $long = strlen($who);                         //v indicates the table the video is from                
                $Where = substr($who,$long-1);
                $what = substr($who,0,$long-1);
                ?>

                You are calling "$what" before it is defined... I suggest using this instead:

                <?php
                   // get the id from the URL request
                   $who = $_REQUEST['who'];                //example of who is beachtrip.asfv where 
                   $long = strlen($who);                         //v indicates the table the video is from                
                $Where = substr($who,$long-1);
                $what = substr($who,0,$long-1);
                ?> <html> <body> <script language="javascript"> function playIt(){ var Whos = "<?=$what?>"; var WHAT = "C:\Documents and Settings\Player\"; Player.URL = "WHAT" + "Whos" ; Player.controls.play();} function stop() { mePlayer.controls.stop();} </script>

                See if that works. 😃

                  nope.... same errors just diff. line # to go with them.....

                    I take it back....something else is going on now....I am getting the same alert messages but the problem is not appering in the sorce page like it was above...

                      What is the source of the page now? Meaning what is the HTML/JavaScript source when you load the page?

                        Thank you so much for your help!! The errors were in:

                            function playIt(){
                            var Whos = "<?=$what?>";
                            var WHAT = "C:\Documents and Settings\Player\";
                        	Player.URL = "WHAT" + "Whos" ;
                        	Player.controls.play();}
                        
                        

                        changed to:

                          function playIt(){
                            var Whos = "<?=$what?>";
                            var WHAT = "C:\\Documents and Settings\\Player\\";
                        	Player.filename = WHAT + Whos ;}
                        

                        Thank you again for your input!!

                        Brandie1 🙂

                          Write a Reply...