You are here: Re: how do you suppress errors produced by file() « PHP Programming Language « IT news, forums, messages
Re: how do you suppress errors produced by file()

Posted by Kimmo Laine on 08/18/05 06:41

<lkrubner@geocities.com> kirjoitti
viestissδ:1124333726.903172.289640@g47g2000cwa.googlegroups.com...
>
> I'm getting this error:
>
> <b>Warning</b>:
> file(http%3A%2F%2Fwww.publicpen.com%2Fupdate.php%3FcbHeadline%3DTestimonials%26amp%3BcbDateCreated%3D%26amp%3BcbUserName%3D%26amp%3BpageAddress%3Dhttp%3A%2F%2Fwww.publicdomainsoftware.org%2Fgo%2Findex.php%3FpageId%3D33119):
> failed to open stream: No such file or directory in
> <b>/home/httpd/vhosts/publicdomainsoftware.org/httpdocs/go/pdsIncludes/CommandUpdatePublicPen.php</b>
> on line <b>64</b><br />
>
>
>
> these are lines 56-64:
>
>
>
> $url = "http://www.publicpen.com/update.php";
> $url .= "?cbHeadline=$cbHeadline";
> if ($cbHeadline == "") $url .=
> "&amp;cbMainContent=$cbMainContent";
> $url .= "&amp;cbDateCreated=$cbDateCreated";
> $url .= "&amp;cbUserName=$cbUserName";
> $url .= "&amp;pageAddress=$pageAddress";
>
> $url = urlencode($url);
> $arrayOfPublicPenResponse = 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?


You should not urlencode the domain part. This here:
http%3A%2F%2Fwww.publicpen.com%2Fupdate.php%3F 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.com/update.php?";
$query = urlencode("cbHeadline=$cbHeadline");
if ($cbHeadline == "") $query .=
'&'.urlencode("cbMainContent=$cbMainContent");
$query .= '&'.urlencode("cbDateCreated=$cbDateCreated");
$query .= '&'.urlencode("cbUserName=$cbUserName");
$query .= '&'.urlencode("pageAddress=$pageAddress");

$arrayOfPublicPenResponse = file($url.$query);

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.berkeley.edu/>
Kimmo Laine <eternal.erectionN0@5P4Mgmail.com>

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация