SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2000
    Location
    Palo Alto, CA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    reading XML response on remote server using PHP4... urgent

    Hi guys,
    Hope it's good place to ask.
    The server sends XML response like
    (Content-type:text/xml from server)


    <response>
    <some stuff="here" />
    </response>

    I cannot get this output into my application for some reason. It doesnt work as it works with HTML
    files, and it says that:

    Warning: Supplied argument is not a valid File-Handle resource in /home/www/rxml.php on line 9

    ... line 9 ...
    $fp = fread("http://www.some.com/xmlresponse.asp", "r");
    .................

    Which works with regular HTML response.


    Please help me, where I should look? Is it passible to do at all?
    Thank you,
    John.

  2. #2
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think your problem is that fread does NOT open files - it just reads from a file that is already open. Your code should look like this:
    PHP Code:
    $filename = ("http://www.some.com/xmlresponse.asp";
    $fd fopen($filename"r");
    $contents '';
    while (!
    feof($fd)) { 
        
    $contents .= fread($fd,4096); 

    fclose ($fd); 
    That will read the whole of the external file into the $contents variable. I haven't tested this so it might not work, but it should do

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2000
    Location
    Palo Alto, CA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Still errors

    Thank you for reply,
    But I still cannot do this, here is the errors:

    Warning: fopen("http://www.some.com/xml.asp","r") - Bad file descriptor in /home/www/xml/xmlapi.php on line 3

    Warning: Supplied argument is not a valid File-Handle resource in /home/www/xml/xmlapi.php on line 5

    Warning: Supplied argument is not a valid File-Handle resource in /home/www/xml/xmlapi.php on line 6


    Is it even passible to do in PHP?

  4. #4
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's possible that your server does not have accessing external files via HTTP enabled - you'll need to check the settings in the php.ini file.

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2000
    Location
    Palo Alto, CA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can you please explain where I should change something?

    Can you please explain to me what should be changed in php.ini? I'm on Slackware Linux 7.1, kernel 2.2.16, php4.01. I've posted same question
    on phpbuilder, but have no replies. Is it so advanced that people have no clue or what? I dunno if I should stick with Perl.... so much trouble with PHP. I hope you can help me,
    Thanks so much,
    John.

  6. #6
    SitePoint Enthusiast
    Join Date
    Apr 2000
    Location
    Palo Alto, CA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    fopen for http ftp

    I've checked my php.ini, i have fopen for http, ftp (to use it as regular file) set to on. Probably PHP isn't good enough for this.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •