Re: [PHP] Using fopen() to open a php file with variables.

2002-12-11 Thread Philip Olson

Why don't you just use include?

 $month = 12;
 $year  = 2002;

 // This include has access to the above variables
 include 'make_calendar.php3';

Include it wherever you intended to print $caledar_html.
It doesn't exist in your code because the url is seen as 
part of the filename.

Regards,
Philip Olson


On Wed, 11 Dec 2002, Jay (PHP List) wrote:

> Okay, I need to retrieve the output of a php file with variables being
> passed to it.  Example:
> 
> $calendar_file = "make_calendar.php3?month=$month&year=$year";
> $fp = $fp = fopen("$calendar_file", "r");
> while (!feof ($fp)) {
>   $buffer = fgets($fp, 4096);
>   $calendar_html .= $buffer;
> }
> fclose($fp);
> 
> It gives me an error that the file doesn't exist, but it does.  Any
> suggestions?
> 
> Jay Douglas
> Systems Consultant
> Fort Collins, CO
> 
> 


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




Re: [PHP] Using fopen() to open a php file with variables.

2002-12-11 Thread Chris Wesley
On Wed, 11 Dec 2002, Jay (PHP List) wrote:

> Okay, I need to retrieve the output of a php file with variables being
> passed to it.  Example:
>
> $calendar_file = "make_calendar.php3?month=$month&year=$year";
> $fp = $fp = fopen("$calendar_file", "r");

Oh my!  That's not going to work, because
"make_calendar.php3?month=$month&year=$year" is not a file in your
filesystem.  I'd start making suggestions on what you can do to achieve
the same effect, but I think it'd be easier if you told us what it is you
want to achieve by doing that.  (It would for me, at least.  Then I'll
start making suggestions.)

THX,
~Chris



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




Re: [PHP] Using fopen() to open a php file with variables.

2002-12-11 Thread Brad Bulger

if you have URL wrappers enabled, do

$fp = fopen("http://path/to/your/file/$calendar_file";, 'r');

On Wed, 11 Dec 2002, Jay (PHP List) wrote:

> Okay, I need to retrieve the output of a php file with variables being
> passed to it.  Example:
>
> $calendar_file = "make_calendar.php3?month=$month&year=$year";
> $fp = $fp = fopen("$calendar_file", "r");
> while (!feof ($fp)) {
>   $buffer = fgets($fp, 4096);
>   $calendar_html .= $buffer;
> }
> fclose($fp);
>
> It gives me an error that the file doesn't exist, but it does.  Any
> suggestions?
>
> Jay Douglas
> Systems Consultant
> Fort Collins, CO
>
>

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




RE: [PHP] Using fopen() to open a php file with variables.

2002-12-11 Thread John W. Holmes
> Okay, I need to retrieve the output of a php file with variables being
> passed to it.  Example:
> 
> $calendar_file = "make_calendar.php3?month=$month&year=$year";
> $fp = $fp = fopen("$calendar_file", "r");
> while (!feof ($fp)) {
>   $buffer = fgets($fp, 4096);
>   $calendar_html .= $buffer;
> }
> fclose($fp);
> 
> It gives me an error that the file doesn't exist, but it does.  Any
> suggestions?

No, it doesn't exist. You have a file make_calendar.php3 on your system,
not what you've listed above. If you want to do it like that, fopen() it
with a full address:

fopen("http://yourdomain.com/make_calendar.php3?month=$month&year=$year";
);

Hopefully the email doesn't mangle that link...

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/




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