Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resource id #55, Error

Status
Not open for further replies.

tewari68

Programmer
Jan 25, 2005
87
US
Hi,
I am trying to write to a file the output from an http GET request, however the file is not completely written and I can see the following message Resource id #55 about half way through writing the file.
Here is my code
Code:
$filename = "orderDet_".$x."xml";
                                        $requestURL = "[URL unfurl="true"]https://services.abc.com/Labcenter/G[/URL]
etOrderXML.asp?mlrfnbr=1109&order=".$x."&password=";
                                        $response = file_get_contents($requestURL);
                                        $fp = fopen($requestURL, "r");
                                        $contents = fread($fp, 1000);
                                        fclose($fp);
                                        //echo $request;
                                        $fp1 = fopen($filename, "w", strlen($requestURL));
                                        $write = fputs($fp1, $contents);
                                        fputs($fp1, $fp);
                                        fclose($fp1);

the output of this code is
Code:
<?xml version="1.0" standalone="yes"?>^M
<?xm-well_formed path = ""?>^M
<Order ID="801">^M
        <OrderTime>2006-09-30 12:08:35</OrderTime>^M
        <Dealer Name="Circle Graphics"><Street1>test</Street1><Street2></Street2><City>test</Cit
y><State>CO</State><ZIP>80302</ZIP><Country>USA</Country><MerchantID>58</MerchantID><LocationNot
e></LocationNote></Dealer><Portal Name=""/><Customer ID="kmcdonal@hotmail.com"><First>Ken</First
><Last>McDonald</Last><BillTo><First>Ken</First><Last>McDonald</Last><Street1>Marketing Stuffers
</Street1><Street2>LifePics</Street2><City>boulder</City><State>CO</State><ZIP>80301</ZIP><Phone
>(303)413-9500 249</Phone><Country>USA</Country></BillTo><ShipTo><First>Ken</First><Last>McDonal
d</Last><Street1>Marketing Stuffers</Street1><Street2>LifePics</Street2><City>boulder</City><Sta
te>CO</State><ZIP>80301</ZIP><Phone>(303)413-9500 249</Phone><Country>USA</Country><Comment>Ship
 via UPS : Ground</Comment></ShipTo></Customer><SpecialInstructions><Message></Message></Special
InstructioResource id #55
I also want to retain the original formatting
Appreciate any help in this regards,
Thanks,
Tewari
 
your code is all jumbled up... let me suggest:

Code:
filename = "orderDet_".$x."xml";
$requestURL = "[URL unfurl="true"]https://services.abc.com/Labcenter/GetOrderXML.asp?mlrfnbr=1109&order=".$x."&password=";[/URL]
$response = file_get_contents($requestURL);
$fp1 = fopen($filename, "w");
fwrite($fp1,$response);
fclose($fp1);

strictly speaking, the functionality of the above code is, get all the contents from the URL'd file at $requestURL, and dump them into a file called "filename". This seems to be what you want, correct?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top