0

This snippet worked in php5.6, but not in php7.

mp3: <script language = "php"> echo "\"" . $MP3FILE . "\"";</script>

The error is: Uncaught SyntaxError: Unexpected token < (I have confirmed that php7 is functioning and processing php files on my server.)

The site is: DNSpanishEnglish.php where it works under php5.6. Here's the whole statement, just for context.

$(document).ready(function(){
  $("#jQ_jP").jPlayer( {
          ready: function () {
                  $(this).jPlayer("setMedia", {
                         mp3: <script language = "php"> echo "\"" . $MP3FILE . "\"";</script>
                // Defines the mp3 url
          });
         startingTime = 45;
         //endingTime = $(this).jPlayer("status", "duration");
         //myAlert( "  endingTime is " + endingTime);
                  $(this).jPlayer("play", 45);  // THIS WORKS!!!!!
                  //$(this).jPlayer("play").jPlayer("stop").jPlayer("playHead", ).jPlayer.status.currentTime);
                  //$(this).jPlayer("playHead", {time: 50});
                  //$(this).jPlayer("play" , { time: 45 }); // works (required for auto-play), but the time args doesnt work.
          //  $(this).jPlayer("playHeadTime" , { time: 45000 });
         $("#jQ_jP").bind($.jPlayer.event.play, function(event) {
                  // Add a listener to report the time play began
                  //myAlert("HELLO from jplayer_1" +
                         //"Play began at time = " +
                  //     event.jPlayer.status.currentTime
                                  //);  // OK, this is happening.
                  //$("#jQ_jP").playHead(50); //doesnt work.
                  $("#jQ_jP").playHeadTime(45000);
                        // milliseconds. doesnt work.
         });
         $("#jQ_jP").playHeadTime(5000); // doesnt work.
          } // End of "ready". No semicolon here!
 });
});
1
  • 1
    Why <script language="php">? Why not <?php? Or even better, <?=. Commented May 20, 2018 at 3:27

2 Answers 2

2

This will happen due to the newer version of PHP7 remove these tag supports. you can use standard tags instead of it like or . Hope this will help you. From PHP official Website

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! That works. I wrote a note to self from 2011 that <? does not work, only <?php. I don't know that's still true.
0

Define your variable elsewhere in php and you can use it in that script.

PHP

$MP3FILE = <?php echo $MP3fileLink ?>

JS

$(document).ready(function(){
  $("#jQ_jP").jPlayer( {
          ready: function () {
                  $(this).jPlayer("setMedia", {
                         mp3: $MP3FILE 
                // Defines the mp3 url
          });
         startingTime = 45;
         //endingTime = $(this).jPlayer("status", "duration");
         //myAlert( "  endingTime is " + endingTime);
                  $(this).jPlayer("play", 45);  // THIS WORKS!!!!!
                  //$(this).jPlayer("play").jPlayer("stop").jPlayer("playHead", ).jPlayer.status.currentTime);
                  //$(this).jPlayer("playHead", {time: 50});
                  //$(this).jPlayer("play" , { time: 45 }); // works (required for auto-play), but the time args doesnt work.
          //  $(this).jPlayer("playHeadTime" , { time: 45000 });
         $("#jQ_jP").bind($.jPlayer.event.play, function(event) {
                  // Add a listener to report the time play began
                  //myAlert("HELLO from jplayer_1" +
                         //"Play began at time = " +
                  //     event.jPlayer.status.currentTime
                                  //);  // OK, this is happening.
                  //$("#jQ_jP").playHead(50); //doesnt work.
                  $("#jQ_jP").playHeadTime(45000);
                        // milliseconds. doesnt work.
         });
         $("#jQ_jP").playHeadTime(5000); // doesnt work.
          } // End of "ready". No semicolon here!
 });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.