shage Posted April 8, 2009 Share Posted April 8, 2009 <?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 More sharing options...
Daniel0 Posted April 8, 2009 Share Posted April 8, 2009 I don't see you calling fwrite. Link to comment https://forums.phpfreaks.com/topic/153103-curl-missing-something/#findComment-804270 Share on other sites More sharing options...
shage Posted April 8, 2009 Author Share Posted April 8, 2009 do i need fwrite, if i declare the variable as a static variable inside the loop it will download google image x amount of times and name it 1_'ID'.jpg, depending on the id Link to comment https://forums.phpfreaks.com/topic/153103-curl-missing-something/#findComment-804491 Share on other sites More sharing options...
Daniel0 Posted April 8, 2009 Share Posted April 8, 2009 Oh, I didn't see you used CURLOPT_FILE. Anyway, try to echo it instead of saving it to see if it actually downloads the file. Link to comment https://forums.phpfreaks.com/topic/153103-curl-missing-something/#findComment-804549 Share on other sites More sharing options...
shage Posted April 8, 2009 Author Share Posted April 8, 2009 if i echo out $thumb is shows every thumb url, but if i have it download i get 0bytes images, thanks for helping man Link to comment https://forums.phpfreaks.com/topic/153103-curl-missing-something/#findComment-804592 Share on other sites More sharing options...
shage Posted April 8, 2009 Author Share Posted April 8, 2009 bump for help Link to comment https://forums.phpfreaks.com/topic/153103-curl-missing-something/#findComment-804752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.