Problems fopen like parameter

Problems fopen like parameter

am 06.05.2008 19:53:51 von buzon

I am opening a rss file using fopen.

If I use direct value, it can be opened, but I use a paremeter, I
obtain an error.


This works:

...
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://www.arteglobal.net/news.xml","r") or die("Error
reading RSS data.");
while ($data = fread($fp, 4096))
{
xml_parse($xml_parser, $data, feof($fp))
...

But this one not (Error reading RSS data):

...
$url_rss = "http://www.arteglobal.net/news.xml";
...
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($url_rss,"r") or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
{
xml_parse($xml_parser, $data, feof($fp))
...


Any idea about what is happening?.


Thank you!



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Problems fopen like parameter

am 07.05.2008 02:14:26 von dmagick

buzon@alejandro.ceballos.info wrote:
> I am opening a rss file using fopen.
>
> If I use direct value, it can be opened, but I use a paremeter, I obtain
> an error.
>
>
> This works:
>
> ...
> xml_set_character_data_handler($xml_parser, "characterData");
> $fp = fopen("http://www.arteglobal.net/news.xml","r") or die("Error
> reading RSS data.");
> while ($data = fread($fp, 4096))
> {
> xml_parse($xml_parser, $data, feof($fp))
> ...
>
> But this one not (Error reading RSS data):
>
> ...
> $url_rss = "http://www.arteglobal.net/news.xml";
> ...
> xml_set_character_data_handler($xml_parser, "characterData");
> $fp = fopen($url_rss,"r") or die("Error reading RSS data.");

PHP doesn't care whether you are using a variable or a direct value for
something like this.

Maybe you're doing something to $url_rss between setting it and before
the fopen call.

echo $url_rss;

just before the fopen line. What is it set to?

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Summary: Problems fopen like parameter

am 07.05.2008 04:03:35 von buzon

Thank you Chris, you give me the clue

Using your method discover wrong pair of brackets, that make that
$url_rss become inside a function, so, the variable was look as local
variable, not a global one; then, the value become null.

- Blinded inside the box.


Quoting Chris :
>
> Maybe you're doing something to $url_rss between setting it and before
> the fopen call.
>
> echo $url_rss;
>


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php