Professional Web Applications Themes

what's wrong with this fsockopen() function ? - PHP Development

This script works fine on my redhat9 machine. I use it with Wins PC I get an error. My site is not shown however it is a XML server accessible over simple HTTP post and get. The error is as follows: The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- A name was started with an invalid character. Error processing resource 'http://bud/test.php'. Line 15, Position 30 $fp = fsockopen( $host, 80, &$errno, &$errstr, 120 ); -----------------------------^ <?php $method = "POST"; ...

  1. #1

    Default what's wrong with this fsockopen() function ?

    This script works fine on my redhat9 machine.
    I use it with Wins PC I get an error.
    My site is not shown however it is a XML server
    accessible over simple HTTP post and get.
    The error is as follows:


    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error
    and then click the Refresh button, or try again later.


    --------------------------------------------------------------------------------

    A name was started with an invalid character. Error processing
    resource 'http://bud/test.php'. Line 15, Position 30

    $fp = fsockopen( $host, 80, &$errno, &$errstr, 120 );
    -----------------------------^






    <?php
    $method = "POST";
    $host = "http://xml.verizon.com";
    $usepath="/xml.asp";

    $postdata = "<?xml version=\"1.0\"
    ?><RecordSet><CustomerID>102167270</CustomerID><Record><CustRecNo>1235489</CustRecNo><Address>510
    Vernet</Address><City>Richardson</City><State>TX</State><Zip>75080</Zip><Latitude></Latitude></Record></RecordSet>";

    // uncomment the line below if you want to use the form. make sure
    form is is same directory as script
    // include('melissa_form.htm');



    function pullpage( $method, $host, $usepath, $postdata) {
    # open socket to filehandle
    $fp = fsockopen( $host, 80, &$errno, &$errstr, 120 );

    # user-agent name
    $ua = "Mozilla/1.0";

    if( !$fp ) {
    print "$errstr ($errno)<br>\n";
    }
    else {
    if( $method == "GET" ) {
    fputs( $fp, "GET $usepath HTTP/1.0\n");
    }
    else if( $method == "POST" ) {
    fputs( $fp, "POST $usepath HTTP/1.0\n");
    }

    fputs( $fp, "User-Agent: ".$ua."\n");
    fputs( $fp, "Accept: */*\n");


    if( $method == "POST" ) {
    $strlength = strlen($postdata);

    fputs( $fp,
    "Content-type: text/xml\n");
    fputs( $fp, "Content-length: ".$strlength."\n\n");
    fputs( $fp, $postdata."\n");
    }

    fputs( $fp, "\n");

    $output = "";

    # while content exists, keep retrieving doent in 1K chunks
    while( !feof( $fp ) ) {
    $output .= fgets( $fp, 1024 );
    }

    fclose($fp);
    }

    return $output;
    }


    //To call pullpage() via HTTP POST, do the following:


    $return_content = pullpage( "POST", $host,
    $usepath , $postdata);

    echo $return_content;


    ?>
    Atarikid Guest

  2. #2

    Default Re: what's wrong with this fsockopen() function ?

    Try $fp = fsockopen( $host, 80, $errno, $errstr, 120 );


    --
    ************************************
    MUSIC24SEVEN
    Pioneers of the
    'Digital Entertainment Industry'
    http://music24seven.com
    ************************************
    "Atarikid" <net> wrote in message
    news:com... 
    ------ 
    ?><RecordSet><CustomerID>102167270</CustomerID><Record><CustRecNo>1235489</C
    ustRecNo><Address>510 
    Vernet</Address><City>Richardson</City><State>TX</State><Zip>75080</Zip><Lat
    itude></Latitude></Record></RecordSet>"; 


    L. Guest

  3. #3

    Default Re: what's wrong with this fsockopen() function ?

    Use: $fp = fsockopen( $host, 80, $errno, $errstr, 120 );

    Call-time pass-by-reference has been deprecated - argument passed by
    value; If you would like to pass it by reference, modify the
    declaration of fsockopen(). If you would like to enable call-time
    pass-by-reference, you can set allow_call_time_pass_reference to true
    in your INI file. However, future versions may not support this any
    longer.

    --
    Rahul

    Atarikid <net> wrote in message news:<com>... 
    Rahul Guest

Similar Threads

  1. Replies: 6
    Last Post: March 2nd, 04:34 PM
  2. Replies: 0
    Last Post: July 24th, 06:10 PM
  3. Replies: 0
    Last Post: July 24th, 02:15 AM
  4. Replies: 0
    Last Post: July 18th, 11:53 PM
  5. Replies: 0
    Last Post: July 10th, 04:41 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139