Re: Why Does "function endElement($parser, $name)" Do This?
- From: maria <maria@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 29 Feb 2008 11:55:35 -0500
On Fri, 29 Feb 2008 11:44:40 -0500, maria <maria@xxxxxxxxxxxxxxxxxxx>
wrote:
On Fri, 29 Feb 2008 05:57:02 -0500, Jerry Stuckle
<jstucklex@xxxxxxxxxxxxx> wrote:
maria wrote:
This is kind of strange.
I open a stream called $fh with name, say, "maria", before the
function below, and then I try to write into the file "maria" to no
avail! I keep getting the error:
"fwrite(): supplied argument is not a valid stream resource in ... ".
We can't use a stream to write into inside endElement?
Here is the function
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
fwrite($fh,$title);
printf("<dt><b><a
href='%s'>%s</a></b></dt>",trim($link),htmlspecialchars(trim($title)));
printf("<dd>%s</dd>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
It is part of a PHP-program that reads RSS files and saves them with
certain format added. Everything else works fine.
This piece of code is not mine.
Please help!
maria
You haven't passed $fh to the function, so PHP doesn't have a value for it.
BTW - it's bad practice to use globals. When you call a function, pass
the values you need to that function. If you need to change the values,
pass them by reference.
Jerry,
How do I pass the stream $fh to that function?
I can do it in C++, but not in PHP.
Thanks!
maria
Jerry,
I thought that the function endElement takes only two arguments.
Thanks.
maria
.
- Follow-Ups:
- Re: Why Does "function endElement($parser, $name)" Do This?
- From: Jerry Stuckle
- Re: Why Does "function endElement($parser, $name)" Do This?
- References:
- Why Does "function endElement($parser, $name)" Do This?
- From: maria
- Re: Why Does "function endElement($parser, $name)" Do This?
- From: Jerry Stuckle
- Re: Why Does "function endElement($parser, $name)" Do This?
- From: maria
- Why Does "function endElement($parser, $name)" Do This?
- Prev by Date: Re: Why Does "function endElement($parser, $name)" Do This?
- Next by Date: Re: Why Does "function endElement($parser, $name)" Do This?
- Previous by thread: Re: Why Does "function endElement($parser, $name)" Do This?
- Next by thread: Re: Why Does "function endElement($parser, $name)" Do This?
- Index(es):
Relevant Pages
|