Joer. Posted September 21, 2007 Share Posted September 21, 2007 Hi all, I have a script which if I run more than 50 instances(loop) I get this error or just a blank screen: Warning: domxml_open_file() [function.domxml-open-file]: I/O in /home/eagleboo/public_html/PHP/book.php on line 64 Warning: domxml_open_file() [function.domxml-open-file]: warning : in /home/eagleboo/public_html/PHP/book.php on line 64 Warning: domxml_open_file() [function.domxml-open-file]: failed to load HTTP resource in /home/eagleboo/public_html/PHP/book.php on line 64 Fatal error: Call to a member function on a non-object in /home/eagleboo/public_html/PHP/book.php on line 66 My code is this, I have snipped a ffew things out that shouldnt matter. for($i = 0; $i < 60; $i++){ sleep(.9); $valid[] = checkAmazon($arrayISBN[$i]); if(strlen($valid[$i]) == 0){ $gsu[] = $arrayISBN[$i]; }else{ $countworked++; } } function checkAmazon($isbn){ $isbn=trim($isbn); $amazon=*SNIP* $xml=domxml_open_file($amazon); $root=$xml->document_element(); $want=array("Author", "Title","TotalNew","TotalUsed", "Amount", "URL"); //Author, ISBN, Title, New Price, Used Price, PicURL foreach($want as $now){ $elements=$root->get_elements_by_tagname($now); foreach($elements as $element){ $content=$element->get_content(); $parentNode=$element->parent_node(); $parentTag=$parentNode->tagname(); $xmlResults[]=array("parent"=>$parentTag, "tag"=>$now, "content"=>$content); } } if(!isset($xmlResults)){ return false; }else{ *SNIP* } } $results['isbn']=$isbn; $xml->free(); return $results; } } Not sure what to do in this case. Does anyone know how to free up memory or resources being used? Quote Link to comment https://forums.phpfreaks.com/topic/70211-io-error-when-parsing-many-domxml-docs/ Share on other sites More sharing options...
Joer. Posted September 22, 2007 Author Share Posted September 22, 2007 fclose($xml); I tried that but I get an error since im not using fopen. THere must be some way to clear our the resources used here. I dont need to have them all open while looping through. Just to sum up some of that code for people who dont want to look at it: while loop call function checkAmazon end while function checkAmazon domxml_open_file() parse through it end function THe problem is it will through a I/O error I think because php has run our of resources from never 'closing' of 'freeing' up those xml docs. Quote Link to comment https://forums.phpfreaks.com/topic/70211-io-error-when-parsing-many-domxml-docs/#findComment-352709 Share on other sites More sharing options...
Joer. Posted September 22, 2007 Author Share Posted September 22, 2007 ah I turned off php safe mode on my VPS. Now it seems to be using free(). So that works now I need to figure out why the script is wrong half the time where before it wasnt. [move]ahhh ahhhhh ahhhhh[/move] Quote Link to comment https://forums.phpfreaks.com/topic/70211-io-error-when-parsing-many-domxml-docs/#findComment-352713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.