diabloroker Posted November 18, 2009 Share Posted November 18, 2009 A friend of mine coded this but it suddenly stopped working. After placing the youtube URL into the field, it displays the error, "The video details cannot be retrieved.". We like that the error detection works but why did it break? <?php include('application.php'); if ($myID == 0) goto('login.php'); _v('e;i:eid'); if ($mode == 'e') { $main .= "<center><br><br> The video cannot be found. <br> <br> <br> <input type='button' name='b1' class='bttn' value='< Go Back' onclick=\"location.replace('myvideos.php');\"> </center>"; } if ($mode == 'delete') { $qc = mysql_query("SELECT * FROM `video` WHERE `vid_id` = '$eid' AND `vid_useid` = '$myID'"); if (mysql_num_rows($qc) == 0) goto('myvideos.php'); $rc = mysql_fetch_assoc($qc); extract($rc); if ($vid_thumb != '') @unlink("$base_path/photo/video/$vid_thumb"); $qd = mysql_query("DELETE FROM `video` WHERE `vid_id` = '$eid' AND `vid_useid` = '$myID' LIMIT 1"); goto('myvideos.php'); } // Add From Youtube if ($mode == 'addys') { _v('ttl,dsc,ytc,tags,thumb,v__id,catid'); $now = date('Y-m-d H:i:s'); $url = gen_url($ttl, 60, 'video', 'vid_url'); $fname = ''; if ($m_ytc != '') $hcode = $m_ytc; else $hcode = '<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/'.$v__id.'&hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'.$v__id.'&hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>'; $tags = make_tags($tags, ' '); $qins = mysql_query("INSERT INTO `video` (`vid_useid`, `vid_catid`, `vid_title`, `vid_url`, `vid_desc`, `vid_code`, `vid_date`, `vid_enabled`, `vid_tags`, `vid_thumb`) VALUES ('$myID', '$catid', '$m_ttl', '$url', '$m_dsc', '$hcode', '$now', '1', '$tags', '$fname')") or die(mysql_error()); $last = mysql_insert_id(); $yfile = "http://i2.ytimg.com/vi/$v__id/default.jpg"; $fname = 'vt'.$last.'.'.'jpg'; $thumb = new thumb($yfile, 'jpg', "photo/video/$fname"); $thumb -> fixed(120, 90); if (!file_exists("photo/video/$fname")) $fname = ''; $qupd = mysql_query("UPDATE `video` SET `vid_thumb` = '$fname' WHERE `vid_id` = '$last'"); goto('myvideos.php'); } if ($mode == 'adda') { _v('vurl'); $info = get_youtube_info($vurl); if ($info['error'] != '') { $mode = 'addy'; $e = 1; } else { extract($info); $cj = new jsValid('frmab'); $cj->addf('ttl,catid'); $js = $cj->show(1, 0); $main .= "<form action='myvideos.php' method='post' name='frmab' id='frmab' style='margin:0px' enctype='multipart/form-data'><input type='hidden' name='mode' value='addys'><input type='hidden' name='thumb' value='$thumb'><input type='hidden' name='v__id' value='$v__id'> <table border='0' cellspacing='2' cellpadding='3' align='center' width='400'> <tr><td><b>Title</b>:<br><input type='text' name='ttl' value=\"$title\" class='input' style='width:340px'></td></tr> <tr><td><br><b>Category</b>:<br>".sel_db('catid', 'category', 'cat_id', 'cat_name', "`cat_type` = 'videos'", '', '- Select -', 'input', '', '238')."</td></tr> <tr><td><b>Description</b>:<br><textarea name='dsc' class='input' style='width:340px;height:100px'>$desc</textarea></td></tr> <tr><td><b>Tags</b>: <br><input type='text' name='tags' value=\"$tags\" class='input' style='width:340px'></td></tr> <tr><td align='center'><br><input type='submit' name='sub' class='bttn' value='Add Video'> <input type='button' name='cnc' class='bttn' value='Cancel' onclick=\"location.replace('myvideos.php');\"></td></tr> </table></form>$js"; } } if ($mode == 'edits') { _v('ttl,catid,dsc,tags'); $tags = make_tags($m_tags, ' '); $qupd = mysql_query("UPDATE `video` SET `vid_catid` = '$m_catid', `vid_title` = '$m_ttl', `vid_desc` = '$m_dsc', `vid_tags` = '$tags' WHERE `vid_id` = '$eid' AND `vid_useid` = '$myID'"); goto("$base_url/myvideos.php"); } if ($mode == 'edit') { $qv = mysql_query("SELECT * FROM `video` WHERE `vid_id` = '$eid' AND `vid_useid` = '$myID'"); if (mysql_num_rows($qv) == 0) goto("$base_url/myvideos.php"); $rv = mysql_fetch_assoc($qv); extract($rv); $tags = unmake_tags($vid_tags, ','); $cj = new jsValid('frmab'); $cj->addf('ttl,catid'); $js = $cj->show(1, 0); $main .= tab('Edit Video', 600); $main .= "<form action='myvideos.php' method='post' name='frmab' id='frmab' style='margin:0px' enctype='multipart/form-data'><input type='hidden' name='mode' value='edits'><input type='hidden' name='eid' value='$eid'> <table border='0' cellspacing='2' cellpadding='3' align='center' width='400'> <tr><td><b>Title</b>:<br><input type='text' name='ttl' value=\"$vid_title\" class='input' style='width:340px'></td></tr> <tr><td><br><b>Category</b>:<br>".sel_db('catid', 'category', 'cat_id', 'cat_name', "`cat_type` = 'videos'", $vid_catid, '', 'input', '', '238')."</td></tr> <tr><td><b><br>Description</b>:<br><textarea name='dsc' class='input' style='width:340px;height:100px'>$vid_desc</textarea></td></tr> <tr><td><b>Tags</b>: <br><input type='text' name='tags' value=\"$tags\" class='input' style='width:340px'></td></tr> <tr><td align='center'><br><input type='submit' name='sub' class='bttn' value='Update'> <input type='button' name='cnc' class='bttn' value='Cancel' onclick=\"location.replace('myvideos.php');\"></td></tr> </table></form>$js"; $main .= tabe(); } if ($mode == 'addy') { $main = " <form action='myvideos.php' method='post' name='frmab' id='frmab' style='margin:0px' enctype='multipart/form-data'> <input type='hidden' name='mode' value='adda'> <center><br> Please enter the YOUTUBE URL of the video <br> <i>eq: http://www.youtube.com/watch?v=B5i3mQhtNtg</i><br><br> <input type='text' name='vurl' class='input' style='width:300px'><br><br> <input type='submit' name='sub' class='bttn' value='Continue >'> <input type='button' name='cnc' class='bttn' value='Cancel' onclick=\"location.replace('myvideos.php')\"> </center>"; if ($e == 1) $main .= "<center><font color='red'>The video details cannot be retrieved.</font>"; } if ($mode == '') { $main .= tab2('My Videos', "<input type='button' name='b1' class='bttn' value='Add Youtube Video' onclick=\"location.replace('$base_url/myvideos.php?mode=addy');\">", 650); $main .= "<div style='margin:10px'>"; $qe = mysql_query("SELECT * FROM `video` WHERE `vid_useid` = '$myID' ORDER BY `vid_id` DESC"); if (mysql_num_rows($qe) == 0) $main .= "<center><br>You have not added any videos yet.</center>"; else { $main .= "<table border='0' cellspacing='4' cellpadding='3' width='600' align='center'>"; while ($re = mysql_fetch_assoc($qe)) { extract($re); $thumb = ' '; if ($vid_thumb != '') $thumb = "<img src='photo/video/$vid_thumb' border='0'>"; $vid_desc = mktext($vid_desc, 250); $vlink = URL::video($vid_id, $vid_url); $main .= " <tr> <td width='140' valign='top'><a href='$vlink'>$thumb</a></td> <td width='460' valign='top'> <a class='evtt' href='$vlink'>$vid_title</a> <div style='margin-top:5px;line-height:17px'>$vid_desc</div> <div style='margin-top:3px;color:#555555;line-height:19px'> <a href='myvideos.php?mode=edit&eid=$vid_id'>Edit Video</a> <a href='#' onclick=\"if (confirm('Are you sure you want to delete this video?')==true) location.replace('myvideos.php?mode=delete&eid=$vid_id');\">Delete Video</a></div> </td> </tr><tr><td colspan='2'><div style='border-top:1px solid #C7C7C7;height:2px;margin-top:4px;'> </div></td></tr>"; } $main .= "</table>"; } $main .= "<center><br><br> <input type='button' name='b1' class='bttn' value='Add Youtube Video' onclick=\"location.replace('$base_url/myvideos.php?mode=addy');\"> </center></div>"; $main .= tabe(); $main .= "<div style='line-height:19px;margin-left:20px;margin-bottom:20px'>Easily import your favorite YouTube videos and share them with members. No uploading required. <br /> <a href='".URL::page('faq')."'>Support</a> </div>"; } $_vtemplate['main'] = $main; $_vtemplate['right'] = $right; $tp = new page($_vtemplate, 'template/default2.html'); Quote Link to comment https://forums.phpfreaks.com/topic/181972-youtube-integration/ Share on other sites More sharing options...
oni-kun Posted November 18, 2009 Share Posted November 18, 2009 Your error reporting lacks the correct error reporting, ironically. "Cannot be retrieved.." is not helpful. Debug your code, add checks on every bit of the code, ESPECIALLY seeing if the video path EXISTS, as youtube, bans certain hosts and changes its locations/videos at will. It's most likely some simple parsing problem though.. Quote Link to comment https://forums.phpfreaks.com/topic/181972-youtube-integration/#findComment-959832 Share on other sites More sharing options...
diabloroker Posted November 18, 2009 Author Share Posted November 18, 2009 I appreciate the assistance but I've been looking at this code for awhile now, I can't seem to find why its not pulling youtube videos anymore. I'm aware that youtube changes locations but we haven't ran into that problem yet. Quote Link to comment https://forums.phpfreaks.com/topic/181972-youtube-integration/#findComment-959842 Share on other sites More sharing options...
oni-kun Posted November 18, 2009 Share Posted November 18, 2009 Is the "The video details cannot be retrieved." from Youtube or your code? If it's from your code then. 1) Find the error, and WHY it was triggered. 2) work your code/logic around it. If you can't, find then do the same with your other functions. It doesn't look that hard to solve. Quote Link to comment https://forums.phpfreaks.com/topic/181972-youtube-integration/#findComment-959849 Share on other sites More sharing options...
diabloroker Posted November 19, 2009 Author Share Posted November 19, 2009 Its from the code, not youtube. Oni-kun, the reason why I'm posting on this forum is to receive help on the code. I've already tried finding the error and seeing why it was triggered. I've attempted to work the code around but nothing has worked. Quote Link to comment https://forums.phpfreaks.com/topic/181972-youtube-integration/#findComment-960816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.