Can anyone help me with this code? I have been trying to output the url as a link but I cannot manage to do so. The url comes out fine in text form but when I try to output the url as a link I either get an error message or all of the url is not in the link. The code works without errors as I have it posted here but all of the url does not appear in the link. It seems anything I add after video_id. either produces and error or the var lable is output instead of the var value. I have been working on this for hrs. I know it must be something simple but I just cannot figure it out.

Thanks in advance

Kanui

<?php

$txt = file_get_contents('http://youtube.com/watch?v=Z_qBWLAdKoE');

preg_match('/video_id:\'[\w]{11}\'/', $txt, $video_id_temp);
preg_match('/[\w]{11}/',$video_id_temp[0],$video_id_temp2);
$video_id = $video_id_temp2[0];

preg_match('/l:\'[\d]{1,15}\'/',$txt,$l_temp);
preg_match('/[\d]{1,15}/',$l_temp[0],$l_temp2);
$l = $l_temp2[0];

preg_match('/t:\'[\w]{32}\'/',$txt,$t_temp);
preg_match('/[\w]{32}/',$t_temp[0],$t_temp2);
$t = $t_temp2[0];

echo "http://youtube.com/get_video.php?video_id=".$video_id."&l=".$l."&t=".$t;
$url="http://youtube.com/get_video.php?video_id=";

print "<td><tr><a href='".$url.$video_id."'>   Download</a></td></tr>";<?php

$txt = file_get_contents('http://youtube.com/watch?v=Z_qBWLAdKoE');

preg_match('/video_id:\'[\w]{11}\'/', $txt, $video_id_temp);
preg_match('/[\w]{11}/',$video_id_temp[0],$video_id_temp2);
$video_id = $video_id_temp2[0];

preg_match('/l:\'[\d]{1,15}\'/',$txt,$l_temp);
preg_match('/[\d]{1,15}/',$l_temp[0],$l_temp2);
$l = $l_temp2[0];

preg_match('/t:\'[\w]{32}\'/',$txt,$t_temp);
preg_match('/[\w]{32}/',$t_temp[0],$t_temp2);
$t = $t_temp2[0];

echo "http://youtube.com/get_video.php?video_id=".$video_id."&l=".$l."&t=".$t;
$url="http://youtube.com/get_video.php?video_id=";

print "<td><tr><a href='".$url.$video_id."'>   Download</a></td></tr>";

I got it...well, this works anyway :)

<?php

$txt = file_get_contents('http://youtube.com/watch?v=Z_qBWLAdKoE');

preg_match('/video_id:\'[\w]{11}\'/', $txt, $video_id_temp);
preg_match('/[\w]{11}/',$video_id_temp[0],$video_id_temp2);
$video_id = $video_id_temp2[0];

preg_match('/l:\'[\d]{1,15}\'/',$txt,$l_temp);
preg_match('/[\d]{1,15}/',$l_temp[0],$l_temp2);
$l = $l_temp2[0];

preg_match('/t:\'[\w]{32}\'/',$txt,$t_temp);
preg_match('/[\w]{32}/',$t_temp[0],$t_temp2);
$t = $t_temp2[0];

$test="&l=".$l;
$test2="&t=".$t;

$url="http://youtube.com/get_video.php?video_id=";

print "<td><tr><a href='".$url.$video_id.$test.$test2."'>   Download it!</a></td></tr>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.