2017-04-15 88 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>