Jump to content

kitenski

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kitenski's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Morning all, I am using CURL to download an image file within a loop. The first time it runs fine and I see the image appear in the directory. The second time it fails with a timeout, despite it being a valid URL. Can anyone suggest why it always fails on the 2nd time and how to fix it? The snippet of code is: // download image $extension = "gif"; $ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 90); curl_setopt($ch, CURLOPT_URL, $imgurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); echo $imgurl . " attempting to open URL "; $i = curl_exec($ch); if ( $i==false ) { echo curl_errno($ch).' '.curl_error($ch); } $image_name=time().'.'.$extension; $f = fopen('/fulldirectorypath/' . $image_name ,'w+'); fwrite($f,$i); fclose($f); I have put an echo in there to display the $IMGURL, to check it is valid, and upped the timeout to 90 secs, but it still fails. I have also added a 240 sec sleep within the loop, but I still get the same error. This is what I see on screen: http://images.eu-xmedia.de/thumbnails/34555861/5676051/pt=pic,lang=2,origfile=yes/image.gif attempting to open URL 28 Operation timed out after 90 seconds with 0 bytes received an empty file is created in my directory. thanks alot, Greg
  2. Good morning, I am trying to extract some data from a XML file. I have the basics working, but I am having problems getting it to pull out the software ID. Using a simple XML file as an example, I cannot get my php to pull out the unique software id <?xml version="1.0" encoding="UTF-8"?> products count="5" rendertime="1.620"> <software id="5667391" added="2010-05-27" updated="2010-05-27"> <title><![CDATA[World Cup South Africa 2010 Scoreboard 1.0.1]]></title> <name><![CDATA[World Cup South Africa 2010 Scoreboard]]></name> <short_description><![CDATA[This program automates all the scores, schedules and rankings of all matches at the FIFA 2010 Soccer World Cup in South Africa.]]></short_description> </software> </products> My relevant PHP section is as follows: $xmlReader = new XMLReader (); $filename="/files/testfile.xml"; $xmlReader ->open($filename); while ($xmlReader->read()) { switch ($xmlReader->name) { case 'software': $dom = new DOMDocument(); $domNode = $xmlReader->expand(); $element = $dom->appendChild($domNode); $domString = utf8_encode($dom->saveXML($element)); $product = new SimpleXMLElement($domString); //read in data $name = $product->name; $description = $product->short_description; $software_id = $product->id; echo $software_id . "software ID <br />"; echo $name . "name <br />"; echo $description . "description <br />"; It pulls out the name and description succesfully, but not the software id. Can anyone suggest what I am doing wrong please? I have also tried changing the software_id line to the following, but that also returns a blank $software_id = $product->'software id'; I've about reached my technical limits, googling on SimpleXMLElement($domString); hasn't helped at all Thanks in advance, Greg
×
×
  • 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.