Jump to content

problem with getting youtube video thumbnail in php


doforumda

Recommended Posts

hi

I am fetching thumbnails of youtube videos but it does not show up. I am doing this using PHP, JQuery ajax. The problem is it does not show any error. it displays all the links to thumbnails but it does not display it.

Here is my code

 

<?php
require("database/db.php");
include "functions/ytVideoId.php";

$getVideos = mysql_query("SELECT * FROM dc_videos LIMIT 9");
if(mysql_numrows($getVideos) > 0) {
    while($rowVideos = mysql_fetch_assoc($getVideos)) {
        $video = $rowVideos['videoUrl'];
        $videoId = ytVideoId($video);
        echo "http://i1.ytimg.com/vi/$videoId/default.jpg ";
    }
} else 
    echo "No videos found!";
?>

 

here is my javascript file

$(function() {
   $('#tabBody').click(function(){
      $('#tabBody').addClass('tabActive');
      //alert("hello");
      var url = "videos.php";
      $.ajax({
          type: 'POST',
          url: url,
          success: function(result) {
              alert(result);
              $('#videoList').html("<img src='" + result + "' alt='Preview Not Available' />");
          }
      });
   });
});

 

this is what i get as a result in js file

http://i1.ytimg.com/vi/VjWJhA_4M9g/default.jpg http://i1.ytimg.com/vi/Rln9Z7w1A1w/default.jpg http://i1.ytimg.com/vi/GXK6tf16ue8/default.jpg http://i1.ytimg.com/vi/Uq1jsb9LqHo/default.jpg http://i1.ytimg.com/vi/Yg7K36i8B4c/default.jpg http://i1.ytimg.com/vi/YVwcbI8iuxo/default.jpg http://i1.ytimg.com/vi/xqvxlhqGHTY/default.jpg http://i1.ytimg.com/vi/PHk302o4VFk/default.jpg http://i1.ytimg.com/vi/hSuik_fu-WM/default.jpg

please help

Link to comment
Share on other sites

ok here is my html page

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link type="text/css" rel="stylesheet" href="css/styles.css" />
        <script type="text/javascript" src="js/jquery-lib.js"></script>
        <script type="text/javascript" src="js/script.js"></script>
        <title>Dream City</title>
    </head>
    <body>
        <?php $_SESSION['userid'] = "1"; $_SESSION['username'] = "zafar"; ?>
        <div id="contents">
            <div id="tabsContainer">
                <div id="tabBody" class="tabs">Body</div>
                <div id="tabMind" class="tabs">Mind</div>
                <div id="tabBusiness" class="tabs">Business</div>
                <div id="tabArts" class="tabs">Arts</div>
                <div id="tabEnvironment" class="tabs">Environment</div>
            </div><!-- tabsContainer -->
            
            <div id="tabsContentsWrapper">
                <div class="haveYourDefinition" id="haveYourDefinition">Have your Definition</div><!-- haveYourDefinition -->
                <div id="videosList" class="list"><ul></ul><div id="videosLoader"></div></div>
                <div class="haveYourDefinitionFooter">Video Title / Username / Date</div>
                
                <div class="haveYourDefinition">Have your Definition</div><!-- haveYourDefinition -->
                <div class="list">Photos</div>
                <div class="haveYourDefinitionFooter">Video Title / Username / Date</div>
            </div><!-- tabsContents -->
            
        </div><!-- contents -->
    </body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.