Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/70211-io-error-when-parsing-many-domxml-docs/
Share on other sites

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.

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.