Php 我无法在我的网页上显示我的视频

Php 我无法在我的网页上显示我的视频,php,html,mysql,video,Php,Html,Mysql,Video,我正在使用php从MYSQL数据库加载视频并将其显示在网页上。视频存储为URL以节省数据库空间。每当我加载网页时,我都会得到播放视频的控件,仅此而已。如何让视频显示出来 <?php session_start(); $connect = mysqli_connect("localhost", "root", "root", "videodata"); ?> <!DOCTYPE html> <html> <head> <title&

我正在使用php从MYSQL数据库加载视频并将其显示在网页上。视频存储为URL以节省数据库空间。每当我加载网页时,我都会得到播放视频的控件,仅此而已。如何让视频显示出来

<?php
session_start();
$connect = mysqli_connect("localhost", "root", "root", "videodata");
?>
<!DOCTYPE html>
<html>
  <head>
    <title>Starter Project</title>
  <meta charset="utf-8">
  <title>HTML5 Audio</title>

    </head>
    <body>

    <?php
  $query = "SELECT * FROM videos";
  $result = mysqli_query($connect, $query);
  if(mysqli_num_rows($result) > 0)
  {
    while($row = mysqli_fetch_array($result))
    {
      ?>
  <video width="320" height="240" controls>
      <source src="<?php echo $row['title']; ?>" type="video/mp4">
      Your browser does not support the video tag.
  </video>
<?php
}
}
?>

  </body>
</html>

起步项目
HTML5音频
  • 标记不需要结束标记

  • 确保文件包含在从
    $row['title']
    返回的路径中

  • <?php 
    session_start(); 
    $connect = mysqli_connect("localhost", "root", "root", "videodata"); 
    ?> 
    <!DOCTYPE html> 
    <html> 
     <head> 
       <title>Starter Project</title> 
       <meta charset="utf-8"> 
       <title>HTML5 Audio</title> 
     </head> 
     <body> 
     <?php 
      $query = "SELECT * FROM videos"; 
      $result = mysqli_query($connect, $query);
      if(mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_array($result)) { 
     ?> 
         <video width="320" height="240" controls> 
          <source src="<?php echo $row['title'];?>" type="video/mp4">
          Your browser does not support the video tag.
         </video> 
      <?php } } ?>
     </body> 
    </html>
    
  • 另外,
    $row[title]
    应更改为
    $row['title']

    <?php 
    session_start(); 
    $connect = mysqli_connect("localhost", "root", "root", "videodata"); 
    ?> 
    <!DOCTYPE html> 
    <html> 
     <head> 
       <title>Starter Project</title> 
       <meta charset="utf-8"> 
       <title>HTML5 Audio</title> 
     </head> 
     <body> 
     <?php 
      $query = "SELECT * FROM videos"; 
      $result = mysqli_query($connect, $query);
      if(mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_array($result)) { 
     ?> 
         <video width="320" height="240" controls> 
          <source src="<?php echo $row['title'];?>" type="video/mp4">
          Your browser does not support the video tag.
         </video> 
      <?php } } ?>
     </body> 
    </html>
    
    
    启动项目
    HTML5音频
    
    除非有多种类型的视频,否则可以使用视频标记的src属性:

    
    
    如果您查看页面的源代码,您会看到视频的“src”是什么?请尝试
    。仍然没有任何内容。Chris视频的src应该是,但它没有显示任何内容。
    var_dump
    您的
    $row
    请问,它是否包含您需要的数据?是的,它确实给了我视频的url。如果有帮助的话,我得到的是:数组(4){[0]=>string(1)“1”[“id”]=>string(1)“1”[1]=>string(66)”/Users/connor/Desktop/homeVideoStreamingStuff/XOPIntro.mp4“[“title”]=>string(66)”/Users/connor/Desktop/homeVideoStreamingStuff/XOPIntro.mp4”}
    <?php
    $getVideo = "select * from videos";
    
    $getVideoRes = mysqli_query($con, $getVideo);
    
    $details = mysqli_fetch_assoc($getVideoRes);
    
    $videoUrl = $details['videoUrl'];
    ?>
    
    <body>
            <video id="lecVideo" width="340" height="200" controls>
            
            <source src="videos/<?php echo $videoUrl;?>" type="video/mp4">
            
            </video>
    
    </body>