This is a code that connects to the data base and takes the first ending entry to assign it to $fname
variable, i am not sure why the variable does not seem to work.
$fname = 1I21Z5wNQ48 .
If i type it in directly like this //www.youtube.com/embed/1I21Z5wNQ48
,it works but if i type the variable in (//www.youtube.com/embed/$fname
), it does not. Gives me a black screen saying "A Error Occurred" (In context to embed link.) Thank you for reading and answering my question
<?php
//Connect Script
$output = "";
$cxn = mysqli_connect("host","Username","Password", "DB");
mysqli_connect("host", "Username", "Password", "DB") or die (mysqli_error($cxn));
//Collect -
$query = mysqli_query($cxn, "SELECT * FROM `links` ORDER BY `id` DESC") or die (mysqli_error($cxn));
$count = mysqli_num_rows($query);
if ($count == 0) {
$output = " No results found ! ";
} else {
while ($row = mysqli_fetch_array($query)) {
$fname = $row['taglink']; // Is currently only outputting the first enntry: 1I21Z5wNQ48
$id = $row['id'];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<iframe width="560" height="315" src="//www.youtube.com/embed/$fname" frameborder="0" allowfullscreen></iframe>
</body>
</html>