Jump to content

[SOLVED] HELP!! fopen problem


jigen7

Recommended Posts

i have here a function that accept a string and url site so that it will search a certain keywords if it is included or mention at a given url but some time fopen cant open a couple of sites, what i need is to have a error trapping so that if fclose cant open that site it will jsut skip the url given and return null??  im having trouble because i need the the variable where the site is so that i can use it in searching all of it line for the string given.. 

 

function search_all($url,$search_criteria){

$size = 0;

 

$the_page = fopen($url, "r"); //i think here is the line where i should edit

 

while(!feof($the_page))

{

  $each_line = fgetss($the_page, 255);

  //echo "$each_line <br>";

    if(eregi($search_criteria, $each_line, $results))

  {

      // for each line where there is a match, increment a counter

 

      $size++;

  }

}

fclose($the_page);

//print("I found $size ocurrences of $search_criteria at $url");

return $size;

 

}

Link to comment
Share on other sites

heres the error

 

Warning: fopen(http://www.yardbyyardfabricsandcrafts.com/store/LDpage.asp?CategoryID=8&Category_Name=Online+Shopping) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 403 Access Denied in E:\wwwroot\htdocs\jigen\google_search\function.php on line 55

 

so how can i trap that error so that i just have to skip checking its content if it cant open that 

 

i also check that the url (http://www.yardbyyardfabricsandcrafts.com/store/LDpage.asp?CategoryID=8&Category_Name=Online+Shopping) is accesable how come it gives me that error

Link to comment
Share on other sites

from a google search i found that to fix these http streams errors u need to update to the latest version of php5 or recompile php4 with larger FD_SETSIZE. If u are on php4 with FD_SETSIZE 1024 on a shared host, i guess theres nothing to do other then wait for them to upgrade to version 5.

Link to comment
Share on other sites

Here our phpinfo so it is not updated enough o well ill just try to ask if it can be updated so that the fopen can be use properly

 

System Windows NT GOLDMINE 5.2 build 3790

Build Date Nov 2 2006 11:50:55

Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"

Server API Apache 2.0 Handler

Virtual Directory Support enabled

Configuration File (php.ini) Path C:\WINDOWS\php.ini

PHP API 20041225

PHP Extension 20060613

Zend Extension 220060519

Debug Build no

Thread Safety enabled

Zend Memory Manager enabled

IPv6 Support enabled

Registered PHP Streams php, file, data, http, ftp, compress.zlib

Registered Stream Socket Transports tcp, udp

Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*

Link to comment
Share on other sites

thx for everyone helping me in my prob i got the proper coding by using curl library i was able to create another function that checks the url for a certain ketwoord here the final function

 

function search_call($url,$search_criteria){

$size = 0;

 

$ch = curl_init();

// set URL and other appropriate options

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

 

// grab URL, and return output

$output = curl_exec($ch);

 

// close curl resource, and free up system resources

curl_close($ch);

 

if (eregi($search_criteria, $output)) {

    $size = 1;

}

return $size;

 

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.