Jump to content

Curl Missing Something


shage

Recommended Posts

<?php

require('../include/dbconnect.php');                                  
$handle = fopen("videos.txt", "r");
while ($line = fgetcsv($handle, 1000, "|"))
{
$x = mysql_query("SELECT * FROM video WHERE title = '" .mysql_real_escape_string($line[0]). "' AND time = '$line[2]'") or die("Error: ". mysql_error(). " with query ". $x);
if (mysql_num_rows($x) == 1) {
   echo "$title - <font color=\"red\">Already in there</font><br>";
} else {
$sql    = "INSERT INTO video SET title = '" .mysql_real_escape_string($line[0]). "', description = '" .mysql_real_escape_string($line[1])."', time = '" .mysql_real_escape_string($line[2])."', video = '" .mysql_real_escape_string($line[3])."', tags = '" .mysql_real_escape_string($line[4])."', embed = '0', site='Youtube'";
$result = mysql_query($sql);
$VID    = mysql_insert_id();
$thumb = $line[5];
set_time_limit(0);
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; 
ini_set('display_errors',true);//Just in case we get some errors, let us know....
$fp = fopen ('../thumb/1_'.$VID.'.jpg', 'w+');//This is the file where we save the information
$ch = curl_init($thumb);//Here is the file we are downloading
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);

echo $line[0]." - <font color=\"green\">Added</font><br>";}
}
?>

 

 

some reason it doesnt download the thumb it makes the file but some reason the file is just blank any suggestions? Url is right since i echoed it out and it points to working thumb, if i just curl just the thumb it works outside of the loop scratches head

Link to comment
https://forums.phpfreaks.com/topic/153103-curl-missing-something/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.