Undefined function error
Posted: Thu Nov 20, 2008 10:27 pm
The issue seems to be that "file_get_the_contents($url) ; " is causing the error because it is not defined until after the function runs. I attempted to move the whole line below the function and as a result got a 403 error for the whole page.
Code: Select all
<?php
$para = $_GET['para'] ;
$url = "https://siteexplorer.search.yahoo.com/search?p=$para";
$scrape = file_get_the_contents($url) ;
if (isset($_Post['para'])){
function file_get_the_contents($url) {
$ch = curl_init();
$timeout = 10; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}
}
echo $scrape ;
?>
</html>