Been a long day - arguing with curl for the last hour. This simple function just isn't working. $url is populated properly (echo's out what it's supposed to (first thing tested). If I hardcode the $url value this works. ie - $url = 'http://www.pagename.php'; this works just fine.
What the hell am I missing?
Code:
function get_ezinebody($url)
{
echo $url; ////(this is echoing out)
//unique text to determine start goes here
$start = '<div id="body">';
//insert end text here
$end = "<div><p>Article Source:";
//give credit to the originator
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url );
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch) or die ("Couldn't connect to
$url.");
curl_close ($ch);
$startposition = strpos($result,$start);
if($startposition > 0){
$endposition = strpos($result,$end, $startposition);
//add enough chars to include the tag
$endposition += strlen($end);
$length = $endposition-$startposition;
$result = substr($result,$startposition,$length);
echo $result;
}
}
What the hell am I missing?