title: JW Player read from php cannot read video dynamically
body: <p>I am trying to use JWPlayer to play videos on my website. But I cannot get the video served from php dynamically as I'm getting the following error:</p>
  
  <pre>Error loading media: File could not be played</pre> 
  
  <p>My current code is:</p>
  
  <pre><code>&lt;?php
     include('connection.php');//connect to db
     $id = $_GET['id'];//get video id from param
     $video = mysql_query("SELECT * FROM video_table WHERE id = '$id'");//video row from db
     $data = mysql_fetch_assoc($video);
     $ext = pathinfo($data['video_name'], PATHINFO_EXTENSION);
     $file_name = $id . "." . $ext;
     echo $file_name;
  ?&gt;
     &lt;div id="container1"&gt;&lt;/div&gt;
         &lt;script type="text/javascript"&gt;
              jwplayer('container1').setup({
                  'id': 'container1',
                  'type': '&lt;?php echo $ext ?&gt;',
                  'wmode': 'transparent',
                  'flashplayer': 'jwplayer/jwplayer.flash.swf',
                  'file': 'video.php',
                  'provider': 'video',
                  'width': '480',
                  'height': '320',
              });
          &lt;/script&gt;
     &lt;/div&gt;
  </code></pre>
  
  <p><strong>video.php</strong></p>
  
  <pre><code>&lt;?php
      include('connection.php');
      $id = $_GET['id'];
      $video = mysql_query("SELECT * FROM video_table WHERE id = '$id'");
      $data = mysql_fetch_assoc($video);
      $ext = pathinfo($data['video_name'], PATHINFO_EXTENSION);
      $type = pathinfo($data['type'], PATHINFO_EXTENSION);
      $file_name = $id . "." . $ext;//set the file name as saved in upload directory e.g: 1.mp4
  
      header("pragma : no-cache");
      header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
      header("Content-Description: File Transfer");
      header("Content-Type: $type");
      header("Content-Location: upload/$file_name");
      header("Content-Transfer-Encoding: binary");
      header("Content-Length: ".filesize("upload/$file_name"));
      readfile("upload/$file_name");
  ?&gt;
  </code></pre>
  
  <p>However, if I changed the absolute name here <code>(upload/1.mp4) instead of (upload/$file_name)</code> it works and video is provided. How can I get the video dynamically from parameter?</p>