[function.file-get-contents] error


#1

alright guys i am on DH and am getting this error:
[function.file-get-contents]: failed to open stream: HTTP request failed!

here is the snipit of code i believe to be giving off the error message:

//-------------------------

$srch = preg_replace(’/ /’, ‘+’, $_GET[search]);

//-----GET PAGE NUMBER
$url1 = “http://www.esnips.com/t/?st=4&page=” . $p . “&q=” . $srch;
$gurl1 = file_get_contents($url1);
$lstp = explode("<span class=“currentPage”>", $gurl1);

$lstp = explode("", $lstp[1]);

$lstp = explode("’>", $lstp[0]);

$i=0;
while ($i <= 8) {
$pe = $lstp[$i];
$pe = explode("", $pe);
$pe = explode("", $pe[0]);
$pe = $pe[0];
if(is_numeric($pe)){
$bgst = $pe;
}
$i++;
}
$pe = $bgst;

if ($pe > 100) {
$pe = 100;
}

//----END PAGE NUMBER

now i dont get the error message everytime i search just sometimes…

any help would be greatly appreciated


#2

URL file access is denied in DreamHost’s PHP setup. Please use cURL instead.

si-blog
Max discount on any plan with promocode SCJESSEYTOTAL


#3

yeah i figured that would be my problem but i cant seem to get the curl to work either (havnt had to ever use it)

i will send someone like $5 paypal if they can recode those few lines for me…


#4

It should work like this:$url1 = "http://www.esnips.com/_t_/?st=4&page=$p&q=$srch"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5); $gurl1 = curl_exec($ch); curl_close($ch); $lstp = explode("<span class=\"currentPage\">", $gurl1); // script continues as beforesi-blog
Max discount on any plan with promocode SCJESSEYTOTAL