Comments\<\/h3>/",$page)) { $msg .= "photo $photoID has comments! "; //Find the comments within the HTML preg_match("/\

Comments\<\/h3>(.*?)\<\/table>/is",$page,$section); preg_match_all("/class=\"Said\".*?\

\(.*?)\<\/a>.*?\<\/h4>.*?\

(.*?)\.*?Posted(.*?)\..*?\(.*?#comment(.*?)\"/is",$section[1],$comments); //Loop through the comments for ($i=0;$imodify("-$time $unit"); $commentDate_f = $date->format("Y-m-d H:i:s"); //Throw them into the db $selquery = "SELECT CommentID FROM comments WHERE FlickrID = $commentFlickrID"; if (!$commentexists = @ mysql_query ($selquery, $connection)) printMySQLerror(); if (mysql_num_rows($commentexists) == 0) { $userURL = mysql_real_escape_string($userURL, $connection); $userName = mysql_real_escape_string($userName, $connection); $commentBody = mysql_real_escape_string($commentBody, $connection); $insquery = "INSERT INTO comments SET FlickrID = $commentFlickrID, PhotoID = $photoID, UserName = '$userName', UserURL = '$userURL', Comment = '$commentBody', DateCreated = '$commentDate_f'"; if (!$add = @ mysql_query ($insquery, $connection)) { printMySQLerror(); } else { $msg .= " comments added!"; } } } } else { $msg = "photo $photoID does not have comments."; } print "$msg
"; flush(); ob_flush(); sleep(1); #take a breather } } //Sean Huber's CURL library (slightly modified), http://us2.php.net/curl function doRequest($method, $url, $vars) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); if ($method == 'POST') { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); } $data = curl_exec($ch); curl_close($ch); if ($data) { return $data; } else { return curl_error($ch); } } function get($url) { return doRequest('GET', $url, 'NULL'); } function post($url, $vars) { return doRequest('POST', $url, $vars); } function printMySQLerror() { print "Error: " . mysql_errno() . " : " . mysql_error() . "
"; }