title: Fetching videos Using MySql annd php
body: <p>I'm working on a website that takes a user uploaded video and puts the <code>name</code>, <code>size</code>, <code>type</code>, <code>path</code>, and <code>tmp_name</code> into a MySQL database. The <code>upload.php</code> file is below,</p>
  
  <pre><code>&lt;?php 
  
  $is_form_submitted =  (isset($_POST['submit']))?true:false;
  
      if($is_form_submitted)
      {
          //defines variables
          $name=$_FILES['file']['name'];
          $type=$_FILES['file']['type'];
          $size=$_FILES['file']['size'];
          $tmp_name=$_FILES['file']['tmp_name'];
          $target_path="videos/";
  
  
          $allowedTypes   = array("video/wmv","video/avi",
           "video/mpeg","video/mpg","video/mp4");
          $is_valid_type  = (in_array($_FILES['file']['type'],                           $allowedTypes))?true:false;
         if ( $is_valid_type&amp;&amp; ($_FILES["file"]["size"] &lt; 20000000000))
        {
          if ($_FILES["file"]["error"] &gt; 0)
          {
          echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br&gt;";
          }
          else
          {
          echo "Upload:&amp;nbsp; " . $_FILES["file"]["name"] . "&lt;br&gt;";
          echo "Type:&amp;nbsp; " . $_FILES["file"]["type"] . "&lt;br&gt;";
          echo "Size:&amp;nbsp; " . ($_FILES["file"]["size"] / 1024) . " kB&lt;br&gt;";
          echo "Temp file:&amp;nbsp; " . $_FILES["file"]["tmp_name"] . "&lt;br&gt;";
          mysql_query("INSERT INTO vids(name, type, size, tmp_name, target_path)
          VALUES('$name', '$type', '$size', '$tmp_name', '$target_path')");
  
          if (file_exists("images/" . $_FILES["file"]["name"]))
            {
            echo $_FILES["file"]["name"] . " already exists. ";
            }
          else
            {
            move_uploaded_file($_FILES["file"]["tmp_name"],
            "videos/" . $_FILES["file"]["name"]);
            echo "Stored in: " . "videos/" . $_FILES["file"]["name"];
            }
          }
        }
      else
      {
        echo "Invalid file";
      }
  
      }
  ?&gt; 
  </code></pre>
  
  <p>And everything uploads properly but when I go and try to fetch the name and path of the video, it says that <strong>the video player has found no videos that are supported</strong>, so how would I fetch a random video from the database and put it as the source of the video player?
  (the video file is playable in the player, so it is not the video's fault)</p>
  
  <p>Here is the php code within the document code</p>
  
  <pre><code>&lt;?php
  
  $vid_url = "videos/";
      $result = mysql_query("SELECT * FROM `vids` WHERE 1");
      while($row = mysql_fetch_assoc($result))
      {
          echo 
  
          &lt;div name="video"&gt;
          &lt;video width="100%" height="100%" controls&gt;
          &lt;source src=".$vid_url.$row."type="video/mp4"&gt;
       Error: Video Not working
          &lt;/object&gt;
          &lt;/video&gt; 
          &lt;/div&gt;'; 
  
      } 
  ?&gt;
  </code></pre>
  
  <p>And where I am storing the videos is a directory called videos</p>