2017-04-15 87 views
0

我想使用存储在数据库中的代码显示一个youtube嵌入式视频。但它显示一个错误。我在做什么错误..?使用php的YouTube iframe视频

<?php 
    require 'db.php'; 
    $result = $mysqli->query("SELECT * FROM ycodes") or die($mysqli->error()); 
    $row = mysqli_fetch_array($result); 
    echo $row['ycode']; 
    ?> 


    <!DOCTYPE html> 
    <html> 
    <body> 
     <iframe width="560" height="315" src="https://www.youtube.com/embed/<?$row['ycode']?>" frameborder="0" allowfullscreen></iframe> 

    </body> 
    </html 

回答

0
<iframe width="560" height="315" src="https://www.youtube.com/embed/<?$row['ycode']?>" frameborder="0" allowfullscreen></iframe> 

更改为

<iframe width="560" height="315" src="https://www.youtube.com/embed/<?php echo $row['ycode'];?>" frameborder="0" allowfullscreen></iframe>