Thank you very much for helping me. I've learned a lot from this
And now I'm going to concentrate on my new study, which will contain php in the next year
Thanks again, and I hope to see you again if I have future problems!
Moderator: General Moderators
Code: Select all
<?php
// Build query to get results of video Title & Link
$result = mysql_query("SELECT * FROM uservideos") // Select all results from table uservideos
or die ('cannot select table:' .msql_error()); // If error then stop and display mysql error code
// Begin to build table for sql results
echo "<table border=\"0\" width=\"50%\" >"; // initial table width 50% of page
echo "<tr><th width=\"100%\">Titel</th>"; // Title width share is 100%
// Display results in your table
while ($row =mysql_fetch_array($result)){ // Fetch your results and place in an array to call each value
// Make sure you include your css file for your class="example6" to work with the popup function for each video
echo "<tr><td>";
echo "<a class=\"example6\" href=\"".$row['Link']."\" title=\"".$row['Title']."\">".$row['Title']."</a>"; // Includes your CSS class
echo "</td></tr>";
}
echo "</table>";
?> Code: Select all
<?
error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);
$dbservertype='mysql';
$servername='*************';
$dbusername='***************';
$dbpassword='*************';
$dbname='*************';
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
?>Code: Select all
<?php
require_once("connect.php"); // Database connectie bestand
// Verkrijgt hetgene wat de gebruiker heeft ingevvuld
$Title = $_POST["Title"]; // Pakt de titel
$Link = $_POST["Link"]; // Pakt de link
// Set error location link values for Title & Link
$error1 = "uploadvideos.php?e=1&Title=" . $Title . "&Link=" . $Link; // Sets the string value for error redirect on Title
$error2 = "uploadvideos.php?e=2&Title=" . $Title . "&Link=" . $Link; // Sets the string value for error redirect on Link
$error3 = "uploadvideos.php?e=3&Title=" . $Title; // Sets the string value for error redirect on Link but leaves the incorrect Link out
// Check to see user values have something in them
if (empty($Title)) {
header("Location: $error1"); // Direct them back to your form with error Title missing
} elseif (empty($Link)) {
header("Location: $error2"); // Direct them back to your form with error Link missing
} else {
// ************************************** NEW SECTION - CHANGE LINK *************************************
//$Link = "http://www.youtube.com/watch?v=WXy1KhUQMug"; // Link submitted by user
$Find = "watch?v="; // Value to find in $Link
$Locate_Find = strpos($Link, $Find); // Find location of $Find and moves starting point to end of $Find
if ($Locate_Find == TRUE) { // Sets if statement $Find string value found equals TRUE
$Locate_Find = strpos($Link, $Find) + strlen($Find); // Find location of $Find and moves starting point to end of $Find
//echo $Locate_Find . "<br/> "; // Displays value location of $Find
$Strip_Link = substr($Link, $Locate_Find); // Strips everything before $Find including $Find value
//echo $Strip_Link . "<br />"; // Displays new string value $Link
$New_Link = "http://www.youtube.com/embed/" . $Strip_Link; // Create your new link to be save to the database
//echo $New_Link; // Displays new value of $Link
// Insert the values 'Title', 'Link' in your columns within your database (uservideos) table (????????)
$insert = "INSERT INTO uservideos (Title, Link, Video_Id) VALUES ('$Title', '$New_Link', '$Strip_Link')"; // Create string of required actions
mysql_query($insert) OR DIE (mysql_error()); // Saves values in to database or stops on mysql error
header("Location: confirmupload.php"); // redirects to confirmation page
}
// Only executes this if the $Find value is not found in your $Link value and redirects the user to your video_submit.php with error code 3
else { header("Location: $error3"); } // Direct them back to your form with error Incorrect Link Format
}
?>Code: Select all
/* Some stuff goes before here to initialize API connection */
/* Then get started: */
$yt = new Zend_Gdata_YouTube()
$videoEntry = $yt->getVideoEntry('the0KZLEacs'); //Video-ID
$videoThumbnails = $videoEntry->getVideoThumbnails()
echo 'Video: ' . $videoEntry->getVideoTitle() . "\n";
echo 'Video ID: ' . $videoEntry->getVideoId() . "\n";
echo 'Updated: ' . $videoEntry->getUpdated() . "\n";
echo 'Description: ' . $videoEntry->getVideoDescription() . "\n";
echo 'Category: ' . $videoEntry->getVideoCategory() . "\n";
echo 'Tags: ' . implode(", ", $videoEntry->getVideoTags()) . "\n";
echo 'Watch page: ' . $videoEntry->getVideoWatchPageUrl() . "\n";
echo 'Flash Player Url: ' . $videoEntry->getFlashPlayerUrl() . "\n";
echo 'Duration: ' . $videoEntry->getVideoDuration() . "\n";
echo 'View count: ' . $videoEntry->getVideoViewCount() . "\n";
echo 'Rating: ' . $videoEntry->getVideoRatingInfo() . "\n";
echo 'Geo Location: ' . $videoEntry->getVideoGeoLocation() . "\n";
echo 'Recorded on: ' . $videoEntry->getVideoRecorded() . "\n";
Code: Select all
echo "<a class=\"example6\" href=\"".$row['Link']."\" title=\"".$row['Title']."\"><img src=\"http://img.youtube.com/vi/".$row['Video_Id']."/default.jpg\" alt=\"\"/></a>"; // Includes your CSS class
Code: Select all
Look down for update.Code: Select all
$yt = new Zend_Gdata_YouTube();Code: Select all
<?php
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$yt = new Zend_Gdata_YouTube();
// Build query to get results of video Title & Link
$result = mysql_query("SELECT * FROM uservideos") // Select all results from table uservideos
or die ('cannot select table:' .msql_error()); // If error then stop and display mysql error code
// Begin to build table for sql results
echo "<table border=\"0\" width=\"60%\" >"; // initial table width 60% of page
echo "<tr><th width=\"10%\"></th>"; // Title width share is 100%
// Display results in your table
while ($row =mysql_fetch_array($result)){ // Fetch your results and place in an array to call each value
$videoEntry = $yt->getVideoEntry($row['Video_Id']);
// Make sure you include your css file for your class="example6" to work with the popup function for each video
echo "<tr><td>";
echo "<a class=\"example6\" href=\"".$row['Link']."\" title=\"".$row['Title']."\"><img class=\"fleft\" src=\"http://img.youtube.com/vi/".$row['Video_Id']."/default.jpg\" alt=\"\"/></a> '<b>Titel:</b> ' .$videoEntry->getVideoTitle(). <br> '<b>Beschrijving:</b> ' .$videoEntry->getVideoDescription()."; // Includes your CSS class
echo "</td></tr>";
}
echo "</table>";
?>Code: Select all
echo "<a class=\"example6\" href=\"".$row['Link']."\" title=\"".$row['Title']."\"><img class=\"fleft\" src=\"http://img.youtube.com/vi/".$row['Video_Id']."/default.jpg\" alt=\"\"/></a><b>Titel:</b> ".$videoEntry->getVideoTitle()." <br> <b>Beschrijving:</b> ".$videoEntry->getVideoDescription()." "; // Includes your CSS class Code: Select all
echo "<a class=\"example6\" href=\"".$row['Link']."\" title=\"".$row['Title']."\"><img src=\"http://img.youtube.com/vi/".$row['Video_Id']."/default.jpg\" alt=\"".$row['Title']."\"/></a>"; // Includes your CSS class