how do you suppress errors produced by file()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lkrubner@geocities.com

    #1

    how do you suppress errors produced by file()


    I'm getting this error:

    <b>Warning</b>:
    file(http%3A%2F %2Fwww.publicpe n.com%2Fupdate. php%3FcbHeadlin e%3DTestimonial s%26amp%3BcbDat eCreated%3D%26a mp%3BcbUserName %3D%26amp%3Bpag eAddress%3Dhttp %3A%2F%2Fwww.pu blicdomainsoftw are.org%2Fgo%2F index.php%3Fpag eId%3D33119):
    failed to open stream: No such file or directory in
    <b>/home/httpd/vhosts/publicdomainsof tware.org/httpdocs/go/pdsIncludes/CommandUpdatePu blicPen.php</b>
    on line <b>64</b><br />



    these are lines 56-64:



    $url = "http://www.publicpen.c om/update.php";
    $url .= "?cbHeadline=$c bHeadline";
    if ($cbHeadline == "") $url .=
    "&amp;cbMainCon tent=$cbMainCon tent";
    $url .= "&amp;cbDateCre ated=$cbDateCre ated";
    $url .= "&amp;cbUserNam e=$cbUserName";
    $url .= "&amp;pageAddre ss=$pageAddress ";

    $url = urlencode($url) ;
    $arrayOfPublicP enResponse = file($url);



    I don't get the urlencode thing. The file is there, I've checked many
    times, so am I getting an error that says it isn't there?

  • Kimmo Laine

    #2
    Re: how do you suppress errors produced by file()

    <lkrubner@geoci ties.com> kirjoitti
    viestissä:11243 33726.903172.28 9640@g47g2000cw a.googlegroups. com...[color=blue]
    >
    > I'm getting this error:
    >
    > <b>Warning</b>:
    > file(http%3A%2F %2Fwww.publicpe n.com%2Fupdate. php%3FcbHeadlin e%3DTestimonial s%26amp%3BcbDat eCreated%3D%26a mp%3BcbUserName %3D%26amp%3Bpag eAddress%3Dhttp %3A%2F%2Fwww.pu blicdomainsoftw are.org%2Fgo%2F index.php%3Fpag eId%3D33119):
    > failed to open stream: No such file or directory in
    > <b>/home/httpd/vhosts/publicdomainsof tware.org/httpdocs/go/pdsIncludes/CommandUpdatePu blicPen.php</b>
    > on line <b>64</b><br />
    >
    >
    >
    > these are lines 56-64:
    >
    >
    >
    > $url = "http://www.publicpen.c om/update.php";
    > $url .= "?cbHeadline=$c bHeadline";
    > if ($cbHeadline == "") $url .=
    > "&amp;cbMainCon tent=$cbMainCon tent";
    > $url .= "&amp;cbDateCre ated=$cbDateCre ated";
    > $url .= "&amp;cbUserNam e=$cbUserName";
    > $url .= "&amp;pageAddre ss=$pageAddress ";
    >
    > $url = urlencode($url) ;
    > $arrayOfPublicP enResponse = file($url);
    >
    >
    >
    > I don't get the urlencode thing. The file is there, I've checked many
    > times, so am I getting an error that says it isn't there?[/color]


    You should not urlencode the domain part. This here:
    http%3A%2F%2Fww w.publicpen.com %2Fupdate.php%3 F should not be encoded, that
    should be plaintext http://www.publicpen.com/update.php? so you urlencode
    just the query part. And another thing: you use &amp; in html code, but not
    in the query itself, so let's change em back to plain &'s. Plus you should
    encode them either.

    To achieve this, modify your code a bit:
    $url = "http://www.publicpen.c om/update.php?";
    $query = urlencode("cbHe adline=$cbHeadl ine");
    if ($cbHeadline == "") $query .=
    '&'.urlencode(" cbMainContent=$ cbMainContent") ;
    $query .= '&'.urlencode(" cbDateCreated=$ cbDateCreated") ;
    $query .= '&'.urlencode(" cbUserName=$cbU serName");
    $query .= '&'.urlencode(" pageAddress=$pa geAddress");

    $arrayOfPublicP enResponse = file($url.$quer y);

    Now your handling the URI and the query string separately and encoding just
    the query parameters.

    --
    SETI @ Home - Donate your cpu's idle time to science.
    Further reading at <http://setiweb.ssl.ber keley.edu/>
    Kimmo Laine <eternal.erecti onN0@5P4Mgmail. com>


    Comment

    • lkrubner@geocities.com

      #3
      Re: how do you suppress errors produced by file()

      >You should not urlencode the domain part. This here:[color=blue]
      >http%3A%2F%2Fw ww.publicpen.co m%2Fupdate.php %3F should not be[color=green]
      >>encoded, that[/color]
      >should be plaintext http://www.publicpen.com/updat e.php? so you
      >urlencode
      >just the query part.[/color]

      Thanks, that's useful.


      [color=blue]
      > And another thing: you use &amp; in html code, but not
      > in the query itself, so let's change em back to plain &'s. Plus you should
      > encode them either.[/color]

      No actually, an ampersand by itself is not allowed in any part of the
      url. In the url, you have to use &amp;, not "&". You can not get your
      pages to validate if you are using "&".

      Comment

      • Kimmo Laine

        #4
        Re: how do you suppress errors produced by file()

        <lkrubner@geoci ties.com> kirjoitti
        viestissä:11244 87097.500165.26 180@o13g2000cwo .googlegroups.c om...[color=blue][color=green]
        > >You should not urlencode the domain part. This here:
        >>http%3A%2F%2F www.publicpen.c om%2Fupdate.php %3F should not be[color=darkred]
        >>>encoded, that[/color]
        >>should be plaintext http://www.publicpen.com/updat e.php? so you
        >>urlencode
        >>just the query part.[/color]
        >
        > Thanks, that's useful.
        >
        >
        >[color=green]
        >> And another thing: you use &amp; in html code, but not
        >> in the query itself, so let's change em back to plain &'s. Plus you
        >> should
        >> encode them either.[/color]
        >
        > No actually, an ampersand by itself is not allowed in any part of the
        > url. In the url, you have to use &amp;, not "&". You can not get your
        > pages to validate if you are using "&".[/color]

        Yes, it is allowed in url. It's not allowed in HTML code, but _is_ allowed
        in the url, and in fact you have to use it instead of &amp;. The html code
        gets fucked if & is found without an entity, but when you click on a link,
        the browser converts &amp;'s to plain &'s. When you are accessing a remote
        file with the file() function, you HAVE TO use the plain & url. You don't
        have to believe me, but I'm not making this shit up, I know this for a fact.
        I guess you have to screw it up yourself to believe.

        --
        SETI @ Home - Donate your cpu's idle time to science.
        Further reading at <http://setiweb.ssl.ber keley.edu/>
        Kimmo Laine <eternal.erecti onN0@5P4Mgmail. com>


        Comment

        Working...