I'm building a batabase driven website which uses Javascript to play videos on my website using the YouTube API, but I can't load in the data I have extracted via PHP into the Javascript player.
My table is (Example codes only):
ID | One | Two
---------------
01 | 832 | 943
Here's the PHP code I use to get the data:
<?php
$code_sql = "SELECT * FROM codes WHERE id = '$url_id'";
$code_res = mysqli_query($con, $code_sql);
while($code = mysqli_fetch_assoc($code_res)){
$code_1 = $code["one"];
$code_2 = $code["two"];
};
?>
And Here's the Javascript I'm trying to load it into:
var $vid1 = <?php echo json_encode("$code_1"); ?>;
var $vid2 = <?php echo json_encode("$code_2"); ?>;
var videoIDs = [
'$vid1',
'$vid2'
];
When I load the page it gives me a Invalid Paramiters
in the video player. Any ideas where I'm going wrong?