php - 如何从数据库读取Youtube url?

标签 php html mysql

我正在读取我的数据库,其中包含各种列以及名为 video_games_trailer 的 varchar(500) 列,其中包含 YouTube 视频的 url。到目前为止,一切都显示良好,但在视频应有的位置上,我得到以下内容:

Not Found 
The requested URL /Project/<embed width= was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an 
ErrorDocument to handle the request. 

我正在使用下面的代码显示列

 <?php while($row = mysqli_fetch_array($result)){?>

        <tr>
              <td><iframe width="560" height="315" frameborder="0" 
                allowfullscreen src="<?php echo 
                $row['video_games_trailer'];?>"></iframe></td>
       </tr>
<?php } ?>

在我放入的数据库中

<embed width="560" height="315" src="https://www.youtube.com/embed/whatever">

无论我在哪里看到建议的方法,我是否遗漏了什么以及我可以做什么来解决这个问题?

最佳答案

看起来好像您正在存储

<embed width="560" height="315" src="https://www.youtube.com/embed/whatever">

事实上你应该回显以下内容

 <?php while($row = mysqli_fetch_array($result)){?>

        <tr>
              <td><?php echo 
                $row['video_games_trailer'];?>"></td>
       </tr>
<?php } ?>

但是,您最好只存储 URL 的 watch ID 部分或仅存储 URL。

关于php - 如何从数据库读取Youtube url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49708037/

相关文章:

Javascript:按钮/点击计数器集成在功能中

html - 删除超链接中的下划线

java - 将 Java 图形呈现为 HTML

php - Silex 安全提供商

php - 如何阻止垃圾邮件点击发送到数据库? (php)

php - 即使通过我的 PHP 脚本获得成功 1 后也无法在 android 中发送推送通知

mysql - 将日期更改为商业日期 MyS

php - 当有多棵树时,使用修改后的前序树遍历进行选择

php - 此查询中的 SQL 语法错误在哪里?

php - 如何删除 PHP 中的 CURL 时间限制?