PHP - Cycle Through Videos
Hello everyone i have a quick question to ask if i may.
On my website i have a presentation video on my homepage, with another 1 just made. What i want to do is when people view my website they see the first video as usual but after that finishes i would like it to switch to the next video which will then replace the first video is that possible in php? Similar TutorialsHey guys, How can i break just one cycle of a foreach loop. Example: $arr = array('0','1','2'); foreach ($arr as $value){ if($value == 1){ break from this iteration and continue onto next one} echo $value; } So the output should be 02 I have developed a calendar app. You can add events to certain days, edit, delete them, etc. It works fine now but I'm trying to improve the adding event section. I would like to be able to have a form where there are "name_of_event" and "description" inputs and then display a input that would have a date-picker. I also want to have a link/button that says something to the effect of "add additional day" and then tie a javascript function to it so when it is clicked another date-picker input will pop up under the first, and they'll be able to add as many additional days as they like. I can't figure out how to write the php code that will cycle through only the date-picker inputs though. Something like the following Code: [Select] <?php $name = $_POST['name_of_event']; $description = $_POST['description']; foreach(datepicker_inputs as $date)// <-- part i need help with { mysql_query("INSERT INTO Events (name, description, event_date) VALUES ($name, $description, $date)"); } ?> anybody have ideas on how i can only cycle through the date inputs? I'm pretty sure i'm going to have the date input form name something like "date_1", "date_2", etc. Hello i would like to as a little help on how to proper format an foreach output into an HTML table. I have a small function inside an class, that will retrieve the data of an MySQL table and return the result in 1 array, Outside that function i can get the values displayed i only need to format it to show in an table here's what i have: function that gets the data Code: [Select] function getfansub(){ $subfanarray = array(); $query = mysql_query("SELECT * FROM anr_fansub WHERE 1"); while($result = mysql_fetch_array($query)){ $subfanarray[] = $result; } return $subfanarray; } Outside the funtion/class Code: [Select] $fansubarray = $mysql->getfansub(); VAR_DUMP( $fansubarray ); echo "<br><br>"; foreach($fansubarray as $name){ echo $name['FansubID'] ." ". $name['Designation'] ." ". $name['Website'] ." ". $name['tracker'] ." ". $name['irc'] ."<br>"; } The problem i have with the formating (i really dont know who i can do it) is when he reaches the IRC link he needs to open and close the td and tr brakets of the table. any help or tip is apreciated, thanks in advance I use foreach to echo a list of tags come out of an array as Code: [Select] foreach ($array as $tag) { echo "$tag,"; }This produces "tag1,tag2,tag3,". The problem is the last ",". How to tell the foreach loop to avoid including "," after the last sequence? is there a way to upload video i try uploading video but wont let me Code: [Select] <?php $name = $_FILES['upload']['name']; $ext = strtolower(substr($name,strpos($name,'.') +1)); $size = $_FILES['upload']['size']; $maxsize = 1073741824; $tmp = $_FILES['upload']['tmp_name']; $move = "uploads/"; if(isset($name)){ if(!empty($name)){ if($size <= $maxsize){ if($ext == 'flv' || $ext == 'fla' || $ext == 'mp4'){ if(move_uploaded_file($tmp,$move.$name)){ echo "Uploaded"; }else echo "Error has happen try again later"; }else echo "Image must be a jpg, jpeg, or png"; }else echo "You must select a smaller image size"; }else echo "You must select a image"; } ?> <form action="video.php" method="post" enctype="multipart/form-data" > <input type="file" name="upload" /><br> <input type="submit" name="submitbtn" /> </form> This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=344932.0 Before you say about trying to use curl and fsockopen...I have tried those already but my host does not allow it due to their settings on their php.ini file. I am wondering if there is a way (other than those above) to grab the latest videos from a specific user on youtube, and be able to display them on a website, such as grabbing information about the video, as well as displaying it. If this is at all possible, and you can help...thanks in advance. Can you upload videos to a mysql database? If so how would you go about doing it? Hello, I read somewhere that it is possible for users to be able to upload videos to a website via youtube api intergration. I have no idea how this works, and have tryed the tutorial on the API site. Could anyone give me an example or an easier way that users can upload videos to my website, thanks. i know you get embed code from youtube videos. How do i put the code into my website. Do i store the code in mysql? and how do i get php to display it? hi! i want to upload videos and music files using php but it's not working correctly.through this code imges are uploaded successfully but there is problem with video files ..i hv use php.ini to resolve the size prblem but still its not working..can u give me any code that works perfectly. here is my code.. Collapse <?php ini_set('post_max_size', 5242880); // Set upload limit (5MB) ini_set('upload_max_filesize', 5242880); // Enforce upload limit ini_set('max_execution_time', 2400); // Increase 'timeout' time echo "<form enctype='multipart/form-data' name='form2' method='post' action='video.php?view_id=view'>"; if(isset($_REQUEST['Submit'])) { print_r($_FILES['file2']); $music=($_FILES['file2']['name']); if($_FILES['file2']['error']>0) { echo "error accured"; } else { move_uploaded_file($_FILES['file2']['tmp_name'],"uploadedMusic/".$_FILES['file2']['name']); } } echo "<input name='file2' type= 'file'>"; echo "<input name='Submit' type='submit' value='upload music'>"; echo "</form>"; ?> When i am uploading under 2 MB file, it is successfully uploaded but when i am trying to upload bigger file then its showing failed to upload issue... my code is following....please help me to get out of this situation... Code: [Select] <?php function UploadOne($fname) { $uploaddir = 'uploadedfiles/'; if (is_uploaded_file($fname['tmp_name'])) { $filname = basename($fname['name']); $uploadfile = $uploaddir . basename($fname['name']); if (move_uploaded_file ($fname['tmp_name'], $uploadfile)) $res = "File " . $filname . "was successfully uploaded and stored. Upload More<br>"; include ('../config.php'); mysql_query("INSERT INTO videos (id, path, name, title, content) VALUES ('$_POST[id]', 'url/$filname', '$_POST[date]', '$_POST[title]' , '$_POST[content]')"); $data = mysql_query('SELECT * FROM videos ORDER BY id DESC LIMIT 1'); $info = mysql_fetch_array($data); $res = "<strong>$info[title]</strong>," . "\n Sucessfully Uploaded. \n Upload more". "<br>" . "<a href='../videos.php'>View Videos</a>"; } else $res = "File ".$fname['name']." failed to upload."; return ($res); } ?> Thanks in advance... This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320518.0 I embed YouTube videos on my site.
The problem is, the videos often get deleted by the user, which means that the videos obviously become unavailable on my site.
This happens often, which means that I regularly have to look through my site, find unavailable videos and delete them.
I am looking for an automated way of doing this.
Here's what I've got so far:
<?php $con = mysql_connect("", "", ""); mysql_select_db(""); $qry = "SELECT video_id FROM `table`"; $run = mysql_query($qry, $con); while($row = mysql_fetch_assoc($run)) { $headers = get_headers("http://gdata.youtube.com/feeds/api/videos/{$row['video_id']}"); if(!strpos($headers[0], '200')) { echo "Unavailable: {$row['video_id']}<br />"; return false; } else { echo "Available: {$row['video_id']}<br />"; } } ?>The code's very slow and doesn't work. It produces a list of available videos and then stops when it finds one that is unavailable. The problem is, the video that it says is unavailable is usually available, which means that it's getting it wrong. Is there a faster, more accurate way of doing it? Basically, I want a fast and accurate way of checking the availability of the thousands of videos in my database and I want to produce a list of the ones that are unavailable. Ok say i have a database with users who have a video url field for them to enter a video url to be submitted to the database, im trying to create a page where the videos will be displayed one at a time for example ' 1st video plays then it switches to the next random video from the database and so on' i want only to play so many seconds of the video before it switches as they will be presentations so i dont want viewers to watch them all in full, could anyone help me out with some code or feedback on this please? I have approximately 2,300 videos embedded on my site, and I am constantly adding more. The videos are hosted by YouTube. When a video is deleted from YouTube, it becomes unavailable on my site. Each video's ID is in my MySQL database. A video ID looks like this: ZFOuxAx-dkc I need a script that will do the following: select the IDs from my database check if the videos are still available on YouTube create a list of the videos that are unavailable. If possible, it would be great if the script could also tell me if any of the videos have been blocked in certain countries. The script has to be fully commented so that I can understand it. I want to run the script manually every few days. I don't want to have to change my database tables. I've been told that you can use YouTube's API or YouTube's oEmbed interface. I've also been told that, because there are so many videos, you will have to use cURL multi handles. If interested in this project, please PM me your price. This is an urgent project. I have placed ads elsewhere. |