[PHP] include_once behaves differently in mod_php4 vs php5-cgi

2005-11-30 Thread Toomas Aas

Hello!

There's a website with a following structure

index.php in the site's DocumentRoot directory (for this thread, let's 
call it /www)


functions.php, init.php and db_connect.php in /www/library

index.php includes line:

include_once('library/functions.php');

functions.php includes lines:

include_once('db_connect.php');
include_once('init.php');

The website was running fine under PHP 4.4.0 installed as Apache module.

Then we tried it with PHP 5.0.5 installed as CGI. We got the following 
errors:


PHP Warning:  main() : open_basedir restriction in effect. 
File(/db_connect.php) is not within the allowed path(s): 
(/www:/usr/local/www/phpMyAdmin:/var/tmp/php) in 
/www/library/functions.php on line 2
PHP Warning:  main(db_connect.php) : failed to open stream: Operation 
not permitted in /www/library/functions.php on line 2
PHP Warning:  main() : Failed opening 'db_connect.php' for inclusion 
(include_path='.:') in /www/library/functions.php on line 2


...and similar 3 messages about init.php.

Note that first warning is about '/db_connect.php', not 'db_connect.php' 
or './db_connect.php'. /www/library should be inside the open_basedir, 
since it is under /www, which is listed in open_basedir in php.ini. It 
looks like something is changed in PHP's behaviour between versions 4 
and 5 or is differently handled in CGI vs Apache SAPI, but I find it 
unlikely since I can find no documentation regarding this. It's more 
likely that I am overlooking something trivial, but I can't figure out 
what it is.


I tried to change the include lines to

include_once('./db_connect.php');
include_once('./init.php');

but this made no difference.

However, when I specify the full path:

include_once('/www/library/db_connect.php');
include_once('/www/library/init.php');

then the errors disappear and 'everything' seems to work.

Also, I never get any errors about the

include_once('library/funcions.php');

line in index.php

I'm puzzled...


--
... ASCII stupid question, get a stupid ANSI!

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



[PHP] include_once changed behavior?

2004-06-07 Thread Mattias Thorslund
Hi,
In order to keep configuration files outside the web root I use:
include_once('../config.php');
This used to work also when running php scripts from the command line. 
Now I have a new server and I get no such file or directory when using 
this construct from the command line.

I have worked around this by doing this:
$main_folder = realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/..');
include_once($main_folder . '/config.php');
The original, simpler construct still works when calling the page from a 
web browser, just not when I run it from the command line. 

The new server has a more recent version of PHP (4.3.4). I don't have 
the php version of the old server but it was on RedHat 9 - now I'm on 
Mandrake 10.

What could be the difference that caused this? 

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


Re: [PHP] include_once changed behavior?

2004-06-07 Thread Jason Wong
On Tuesday 08 June 2004 03:21, Mattias Thorslund wrote:

 In order to keep configuration files outside the web root I use:

 include_once('../config.php');

 This used to work also when running php scripts from the command line.
 Now I have a new server and I get no such file or directory when using
 this construct from the command line.

 I have worked around this by doing this:

 $main_folder = realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/..');
 include_once($main_folder . '/config.php');

 The original, simpler construct still works when calling the page from a
 web browser, just not when I run it from the command line.

 The new server has a more recent version of PHP (4.3.4). I don't have
 the php version of the old server but it was on RedHat 9 - now I'm on
 Mandrake 10.

 What could be the difference that caused this?

Possibly:

  manual  Using PHP from the command line  -c switch

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
You have many friends and very few living enemies.
*/

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



Re: [PHP] include_once changed behavior?

2004-06-07 Thread Mattias Thorslund

Jason Wong wrote:
On Tuesday 08 June 2004 03:21, Mattias Thorslund wrote:
 

In order to keep configuration files outside the web root I use:
include_once('../config.php');
This used to work also when running php scripts from the command line.
Now I have a new server and I get no such file or directory when using
this construct from the command line.
I have worked around this by doing this:
$main_folder = realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/..');
include_once($main_folder . '/config.php');
The original, simpler construct still works when calling the page from a
web browser, just not when I run it from the command line.
The new server has a more recent version of PHP (4.3.4). I don't have
the php version of the old server but it was on RedHat 9 - now I'm on
Mandrake 10.
What could be the difference that caused this?
   

Possibly:
 manual  Using PHP from the command line  -c switch
 

...except I don't  use the -c switch? 

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


Re: [PHP] include_once changed behavior?

2004-06-07 Thread Marek Kilimajer
Mattias Thorslund wrote:
Hi,
In order to keep configuration files outside the web root I use:
include_once('../config.php');
This used to work also when running php scripts from the command line. 
Now I have a new server and I get no such file or directory when using 
this construct from the command line.

I have worked around this by doing this:
$main_folder = realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/..');
include_once($main_folder . '/config.php');
The original, simpler construct still works when calling the page from a 
web browser, just not when I run it from the command line.
The new server has a more recent version of PHP (4.3.4). I don't have 
the php version of the old server but it was on RedHat 9 - now I'm on 
Mandrake 10.

What could be the difference that caused this?
/Mattias
cli php uses path relative to your current directory, cgi php uses path 
relative to the executing script.

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


Re: [PHP] include_once changed behavior?

2004-06-07 Thread Marek Kilimajer
Marek Kilimajer wrote:
Mattias Thorslund wrote:
Hi,
In order to keep configuration files outside the web root I use:
include_once('../config.php');
This used to work also when running php scripts from the command line. 
Now I have a new server and I get no such file or directory when 
using this construct from the command line.

I have worked around this by doing this:
$main_folder = realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/..');
include_once($main_folder . '/config.php');
The original, simpler construct still works when calling the page from 
a web browser, just not when I run it from the command line.
The new server has a more recent version of PHP (4.3.4). I don't have 
the php version of the old server but it was on RedHat 9 - now I'm on 
Mandrake 10.

What could be the difference that caused this?
/Mattias
cli php uses path relative to your current directory, cgi php uses path 
relative to the executing script.

You can use
ini_set('include_path', realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/'));
at the beginning of your script as workaround
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] include_once changed behavior?

2004-06-07 Thread Mattias Thorslund
Marek Kilimajer wrote:
cli php uses path relative to your current directory, cgi php uses 
path relative to the executing script.
That IS interesting.  That would explain why:
php /var/www/myproject/util/my-cli-script.php
... will break unless I execute it from that same directory.
I used to be able to do that from anywhere, though - that's why I passed 
the full path to the script.  So it's got to be some configuration 
that's different, or that this behavior has changed.

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


Re: [PHP] include_once changed behavior?

2004-06-07 Thread Jason Wong
On Tuesday 08 June 2004 04:14, Mattias Thorslund wrote:

 What could be the difference that caused this?

As Marek had pointed out the behaviour was changed ...

 Possibly:
 
   manual  Using PHP from the command line  -c switch

 ...except I don't  use the -c switch?

... IIRC just after the change php-cli had a switch that allowed the old 
behaviour, apparently this is not documented in the manual anymore so you 
probably have to use an absolute path.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The whole world is a scab.  The point is to pick it constructively.
-- Peter Beard
*/

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



Re: [PHP] include_once changed behavior?

2004-06-07 Thread Mattias Thorslund
Jason Wong wrote:
Possibly:
manual  Using PHP from the command line  -c switch
From the manual:
The CLI SAPI does not change the current directory to the directory of 
the executed script!

Note: The CGI SAPI supports the CLI SAPI behaviour by means of the -C 
switch when run from the command line. 

In other words, it's possible to make the CGI version work like the CLI 
version (using absolute paths only).  There seems to be no support for 
making CLI work like CGI, however.

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


Re: [PHP] include_once() isnt!

2004-02-07 Thread Adam Bregenzer
On Tue, 2004-02-03 at 17:04, Rob wrote:
 Ive programmed with C/C++ for years and have recently started to dabble in
 PHP. Ive written a multi-part script for a friend and Ive run into a
 problem.
snip
 Heres where the problem lies. Each component is in a separate file, and when
 I run the script, I get an arror saying I cant re-define the classes.
 Which makes me believe that the include_once() function is trying to include
 the other components even though they are already included. So, does that
 mean that include_once() only works right when it is used in the same file?
 It wont recognise that an include was already included in another include?
 Have I confused you yet? I am.

This is not an answer, but it is a solution.  I don't ever rely on
include_once.  If someone else uses my include files they may not use
include_once.  Instead I use the old C/C++ trick of defines:
?php
if (!defined('SOME_INCLUDE')) {
define('SOME_INCLUDE', TRUE);
// Place code here
}
?

I use the following structure for creating unique constants to prevent
collisions:
{projectname}_{classname}( include ? _INC:)

A global class outside my projects:
_CLASS_NAME

The class FooBar in my Rule The World project:
RULE_THE_WORLD_FOO_BAR

The config include in my Rule The World project:
RULE_THE_WORLD_CONFIG_INC


-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



[PHP] include_once() isnt!

2004-02-03 Thread Rob
Ive programmed with C/C++ for years and have recently started to dabble in
PHP. Ive written a multi-part script for a friend and Ive run into a
problem.

Ive got 14 include files 3 of which are basic components that may or may not
be used by other components. One is an authorisation class, another is a
Dbase clas (For MySQL) and another is a file system component.

Now heres the problem. My authorisation component uses the DBase component.
Some of my other components use the DBase component only some of the time
and the Auth and DBase components some of the time and the Auth component
some of the time.  SO... In the Auth component ive included (via
include_once()) the DB component, because it needs it. NOW... in other
modules Ive included (via include_once()) the auth, DB, and gallery
components.
Heres where the problem lies. Each component is in a separate file, and when
I run the script, I get an arror saying I cant re-define the classes.
Which makes me believe that the include_once() function is trying to include
the other components even though they are already included. So, does that
mean that include_once() only works right when it is used in the same file?
It wont recognise that an include was already included in another include?
Have I confused you yet? I am.

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



[PHP] include_once(blah); vs $blah=blah; include($blah);

2002-06-11 Thread Henry

My web hosting company is running  php 4.0.4pl1

Why should it be that these are different

?php

global $root;
include_once(include\blah.php);

?

and

?php

global $root;
$blah=include\blah.php;
include_once($blah);

?

When I say different I mean;

1) global variable are not avaiable in the second version
2) functions defined in the included file are not accessable in the
including file.
3) in both examples the file is included, its just the scope that seem shot

Any answers?

Henry




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




RE: [PHP] include_once(blah); vs $blah=blah; include($blah);

2002-06-11 Thread Jonathan Rosenberg

Out of curiosity, try

?php
 global $root;
 $blah=include\blah.php;
 include_once $blah;
?

 see if it behaves differently (i.e., no parens around the
include file name).

 -Original Message-
 From: Henry [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 11, 2002 8:15 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] include_once(blah); vs $blah=blah;
 include($blah);


 My web hosting company is running  php 4.0.4pl1

 Why should it be that these are different

 ?php

 global $root;
 include_once(include\blah.php);

 ?

 and

 ?php

 global $root;
 $blah=include\blah.php;
 include_once($blah);

 ?

 When I say different I mean;

 1) global variable are not avaiable in the second version
 2) functions defined in the included file are not
 accessable in the
 including file.
 3) in both examples the file is included, its just the
 scope that seem shot

 Any answers?

 Henry




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




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




Re: [PHP] include_once(blah); vs $blah=blah; include($blah);

2002-06-11 Thread Henry

I did as you suggest with an interesting result:

include_once blah.php;

worked

var $blah=blah.php;
include_once $blah;

gave the following error:

Parse error: parse error in including file on line line number


Where the including file is the file that was doing the include!



Previously include_once($blah) just messed up the scoping and global vars!

Henry

Jonathan Rosenberg [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Out of curiosity, try

 ?php
 global $root;
 $blah=include\blah.php;
 include_once $blah;
 ?

  see if it behaves differently (i.e., no parens around the
 include file name).

  -Original Message-
  From: Henry [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, June 11, 2002 8:15 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP] include_once(blah); vs $blah=blah;
  include($blah);
 
 
  My web hosting company is running  php 4.0.4pl1
 
  Why should it be that these are different
 
  ?php
 
  global $root;
  include_once(include\blah.php);
 
  ?
 
  and
 
  ?php
 
  global $root;
  $blah=include\blah.php;
  include_once($blah);
 
  ?
 
  When I say different I mean;
 
  1) global variable are not avaiable in the second version
  2) functions defined in the included file are not
  accessable in the
  including file.
  3) in both examples the file is included, its just the
  scope that seem shot
 
  Any answers?
 
  Henry
 
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 




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




RE: [PHP] include_once(blah); vs $blah=blah; include($blah);

2002-06-11 Thread Jonathan Rosenberg

Hmmm ... does the line number in the error message point to
something in the includeD file?  I.e., might you have some error
in the file you are including?

 -Original Message-
 From: Henry [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 11, 2002 9:11 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] include_once(blah); vs $blah=blah;
 include($blah);


 I did as you suggest with an interesting result:

 include_once blah.php;

 worked

 var $blah=blah.php;
 include_once $blah;

 gave the following error:

 Parse error: parse error in including file on line
 line number


 Where the including file is the file that was doing
 the include!



 Previously include_once($blah) just messed up the
 scoping and global vars!

 Henry

 Jonathan Rosenberg [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Out of curiosity, try
 
  ?php
  global $root;
  $blah=include\blah.php;
  include_once $blah;
  ?
 
   see if it behaves differently (i.e., no parens around the
  include file name).
 
   -Original Message-
   From: Henry [mailto:[EMAIL PROTECTED]]
   Sent: Tuesday, June 11, 2002 8:15 AM
   To: [EMAIL PROTECTED]
   Subject: [PHP] include_once(blah); vs $blah=blah;
   include($blah);
  
  
   My web hosting company is running  php 4.0.4pl1
  
   Why should it be that these are different
  
   ?php
  
   global $root;
   include_once(include\blah.php);
  
   ?
  
   and
  
   ?php
  
   global $root;
   $blah=include\blah.php;
   include_once($blah);
  
   ?
  
   When I say different I mean;
  
   1) global variable are not avaiable in the second version
   2) functions defined in the included file are not
   accessable in the
   including file.
   3) in both examples the file is included, its just the
   scope that seem shot
  
   Any answers?
  
   Henry
  
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 



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




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




Re: [PHP] include_once(blah); vs $blah=blah; include($blah);

2002-06-11 Thread Henry

No, the line number is just of the line in the includING file of the
include_once statement.

It's very odd, is this a known limitation of PHP i..e. includes cannot have
variable or functional file names.

i.e.

It's ok to do
include_once(include/reallyimportantstuff.php);

But it's not ok to do any of the following:

1)
$filename=include/reallyimportantstuff.php;
include_once($filename);

2)
include_once(include./reallyimportantstuff.php);

3)
$root=include;
include_once($root./reallyimportantstuff.php);

?


Henry


Jonathan Rosenberg [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hmmm ... does the line number in the error message point to
 something in the includeD file?  I.e., might you have some error
 in the file you are including?

  -Original Message-
  From: Henry [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, June 11, 2002 9:11 AM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP] include_once(blah); vs $blah=blah;
  include($blah);
 
 
  I did as you suggest with an interesting result:
 
  include_once blah.php;
 
  worked
 
  var $blah=blah.php;
  include_once $blah;
 
  gave the following error:
 
  Parse error: parse error in including file on line
  line number
 
 
  Where the including file is the file that was doing
  the include!
 
 
 
  Previously include_once($blah) just messed up the
  scoping and global vars!
 
  Henry
 
  Jonathan Rosenberg [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   Out of curiosity, try
  
   ?php
   global $root;
   $blah=include\blah.php;
   include_once $blah;
   ?
  
see if it behaves differently (i.e., no parens around the
   include file name).
  
-Original Message-
From: Henry [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 11, 2002 8:15 AM
To: [EMAIL PROTECTED]
    Subject: [PHP] include_once(blah); vs $blah=blah;
include($blah);
   
   
My web hosting company is running  php 4.0.4pl1
   
Why should it be that these are different
   
?php
   
global $root;
include_once(include\blah.php);
   
?
   
and
   
?php
   
global $root;
$blah=include\blah.php;
include_once($blah);
   
?
   
When I say different I mean;
   
1) global variable are not avaiable in the second version
2) functions defined in the included file are not
accessable in the
including file.
3) in both examples the file is included, its just the
scope that seem shot
   
Any answers?
   
Henry
   
   
   
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   
   
  
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 




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




RE: [PHP] include_once(blah); vs $blah=blah; include($blah);

2002-06-11 Thread Jonathan Rosenberg

The examples in the online manual indicate that it is ok to use
the value of a variable for the file name:

http://www.php.net/manual/en/function.include.php

it also shows examples without the parentheses.

Looks like (yet another) PHP bug to me.

Maybe someone more knowledgeable can comment.

 -Original Message-
 From: Henry [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 11, 2002 9:45 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] include_once(blah); vs $blah=blah;
 include($blah);


 No, the line number is just of the line in the
 includING file of the
 include_once statement.

 It's very odd, is this a known limitation of PHP i..e.
 includes cannot have
 variable or functional file names.

 i.e.

 It's ok to do
 include_once(include/reallyimportantstuff.php);

 But it's not ok to do any of the following:

 1)
 $filename=include/reallyimportantstuff.php;
 include_once($filename);

 2)
 include_once(include./reallyimportantstuff.php);

 3)
 $root=include;
 include_once($root./reallyimportantstuff.php);

 ?


 Henry


 Jonathan Rosenberg [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hmmm ... does the line number in the error message point to
  something in the includeD file?  I.e., might you
 have some error
  in the file you are including?
 
   -Original Message-
   From: Henry [mailto:[EMAIL PROTECTED]]
   Sent: Tuesday, June 11, 2002 9:11 AM
   To: [EMAIL PROTECTED]
   Subject: Re: [PHP] include_once(blah); vs $blah=blah;
   include($blah);
  
  
   I did as you suggest with an interesting result:
  
   include_once blah.php;
  
   worked
  
   var $blah=blah.php;
   include_once $blah;
  
   gave the following error:
  
   Parse error: parse error in including file on line
   line number
  
  
   Where the including file is the file that was doing
   the include!
  
  
  
   Previously include_once($blah) just messed up the
   scoping and global vars!
  
   Henry
  
   Jonathan Rosenberg [EMAIL PROTECTED] wrote in message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Out of curiosity, try
   
?php
global $root;
$blah=include\blah.php;
include_once $blah;
?
   
 see if it behaves differently (i.e., no parens
 around the
include file name).
   
 -Original Message-
 From: Henry [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 11, 2002 8:15 AM
 To: [EMAIL PROTECTED]
     Subject: [PHP] include_once(blah); vs $blah=blah;
 include($blah);


 My web hosting company is running  php 4.0.4pl1

 Why should it be that these are different

 ?php

 global $root;
 include_once(include\blah.php);

 ?

 and

 ?php

 global $root;
 $blah=include\blah.php;
 include_once($blah);

 ?

 When I say different I mean;

 1) global variable are not avaiable in the
 second version
 2) functions defined in the included file are not
 accessable in the
 including file.
 3) in both examples the file is included, its just the
 scope that seem shot

 Any answers?

 Henry




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


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



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




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




RE: [PHP] include_once(blah); vs $blah=blah; include($blah);

2002-06-11 Thread Martin Towell

if that's a direct copy of what you've got, then the parse error's probably
to do with the var and not the include_once

var is used only in classes...

-Original Message-
From: Henry [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 11, 2002 11:11 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] include_once(blah); vs $blah=blah;
include($blah);


I did as you suggest with an interesting result:

include_once blah.php;

worked

var $blah=blah.php;
include_once $blah;

gave the following error:

Parse error: parse error in including file on line line number


Where the including file is the file that was doing the include!



Previously include_once($blah) just messed up the scoping and global vars!

Henry

Jonathan Rosenberg [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Out of curiosity, try

 ?php
 global $root;
 $blah=include\blah.php;
 include_once $blah;
 ?

  see if it behaves differently (i.e., no parens around the
 include file name).

  -Original Message-
  From: Henry [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, June 11, 2002 8:15 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP] include_once(blah); vs $blah=blah;
  include($blah);
 
 
  My web hosting company is running  php 4.0.4pl1
 
  Why should it be that these are different
 
  ?php
 
  global $root;
  include_once(include\blah.php);
 
  ?
 
  and
 
  ?php
 
  global $root;
  $blah=include\blah.php;
  include_once($blah);
 
  ?
 
  When I say different I mean;
 
  1) global variable are not avaiable in the second version
  2) functions defined in the included file are not
  accessable in the
  including file.
  3) in both examples the file is included, its just the
  scope that seem shot
 
  Any answers?
 
  Henry
 
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 




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

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




Re: [PHP] include_once(blah); vs $blah=blah; include($blah);

2002-06-11 Thread Jim lucas

is your isp using a unix machine or windows machine?

if they are using a unix box then your backslash needs to be a forward slash
/, and if they are using a windows machine, your backslash needs to be
escaped.  --  \\  other wise you are escaping the b in blah...

Jim Lucas
- Original Message -
From: Martin Towell [EMAIL PROTECTED]
To: 'Henry' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, June 11, 2002 4:31 PM
Subject: RE: [PHP] include_once(blah); vs $blah=blah; include($blah);


 if that's a direct copy of what you've got, then the parse error's
probably
 to do with the var and not the include_once

 var is used only in classes...

 -Original Message-
 From: Henry [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 11, 2002 11:11 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] include_once(blah); vs $blah=blah;
 include($blah);


 I did as you suggest with an interesting result:

 include_once blah.php;

 worked

 var $blah=blah.php;
 include_once $blah;

 gave the following error:

 Parse error: parse error in including file on line line number


 Where the including file is the file that was doing the include!



 Previously include_once($blah) just messed up the scoping and global vars!

 Henry

 Jonathan Rosenberg [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Out of curiosity, try
 
  ?php
  global $root;
  $blah=include\blah.php;
  include_once $blah;
  ?
 
   see if it behaves differently (i.e., no parens around the
  include file name).
 
   -Original Message-
   From: Henry [mailto:[EMAIL PROTECTED]]
   Sent: Tuesday, June 11, 2002 8:15 AM
   To: [EMAIL PROTECTED]
   Subject: [PHP] include_once(blah); vs $blah=blah;
   include($blah);
  
  
   My web hosting company is running  php 4.0.4pl1
  
   Why should it be that these are different
  
   ?php
  
   global $root;
   include_once(include\blah.php);
  
   ?
  
   and
  
   ?php
  
   global $root;
   $blah=include\blah.php;
   include_once($blah);
  
   ?
  
   When I say different I mean;
  
   1) global variable are not avaiable in the second version
   2) functions defined in the included file are not
   accessable in the
   including file.
   3) in both examples the file is included, its just the
   scope that seem shot
  
   Any answers?
  
   Henry
  
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 



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

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




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




[PHP] include_once()

2002-03-19 Thread Mauricio Cuenca

Hello,

I have a very long script with several functions in it. I wanted to split
the script into several files, so I created two sub-scripts and one main
script. This is the code from the main script:

?php

include_once(sub_script_1.php);
incude_once(sub_script_2.php);

$temp = MyFunction();

?

MyFunction() is contained in the file sub_script_1.php which is properly
enclosed with valid PHP start and end tags.

But When I try to run the main script, I get this error:
Fatal error: Call to undefined function: MyFunction()in /main_script.php on
line 4.

How can I properly divide my script into several ones ???

TIA,

__
Mauricio Cuenca



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




Re: [PHP] include_once()

2002-03-19 Thread Neil Freeman

Have you remembered to set up PHP's include_path to point to the area where
your scripts are located?

Neil

Mauricio Cuenca wrote:

 Hello,

 I have a very long script with several functions in it. I wanted to split
 the script into several files, so I created two sub-scripts and one main
 script. This is the code from the main script:

 ?php

 include_once(sub_script_1.php);
 incude_once(sub_script_2.php);

 $temp = MyFunction();

 ?

 MyFunction() is contained in the file sub_script_1.php which is properly
 enclosed with valid PHP start and end tags.

 But When I try to run the main script, I get this error:
 Fatal error: Call to undefined function: MyFunction()in /main_script.php on
 line 4.

 How can I properly divide my script into several ones ???

 TIA,

 __
 Mauricio Cuenca

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

--

 Email:  [EMAIL PROTECTED]
 [EMAIL PROTECTED]




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




Re: [PHP] include_once()

2002-03-19 Thread anders nawroth

Have you put ?php   tags in your include-files?

Anders

- Ursprungligt meddelande - 
Från: Mauricio Cuenca [EMAIL PROTECTED]
Till: [EMAIL PROTECTED]
Skickat: den 19 mars 2002 17:43
Ämne: [PHP] include_once()


 Hello,
 
 I have a very long script with several functions in it. I wanted to split
 the script into several files, so I created two sub-scripts and one main
 script. This is the code from the main script:
 
 ?php
 
 include_once(sub_script_1.php);
 incude_once(sub_script_2.php);
 
 $temp = MyFunction();
 
 ?
 
 MyFunction() is contained in the file sub_script_1.php which is properly
 enclosed with valid PHP start and end tags.
 
 But When I try to run the main script, I get this error:
 Fatal error: Call to undefined function: MyFunction()in /main_script.php on
 line 4.
 
 How can I properly divide my script into several ones ???
 
 TIA,
 
 __
 Mauricio Cuenca
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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




Re: [PHP] include_once()

2002-03-19 Thread Mauricio Cuenca

Yes,

I read the documentation and took close note to include the start and end
tags... ?php  ?

Thanks,

__
Mauricio Cuenca

- Original Message -
From: anders nawroth 
To: Mauricio Cuenca f; [EMAIL PROTECTED]
Sent: Tuesday, March 19, 2002 2:26 PM
Subject: Re: [PHP] include_once()


 Have you put ?php   tags in your include-files?

 Anders

 - Ursprungligt meddelande -
 Från: Mauricio Cuenca 
 Till: 
 Skickat: den 19 mars 2002 17:43
 Ämne: [PHP] include_once()


  Hello,
 
  I have a very long script with several functions in it. I wanted to
split
  the script into several files, so I created two sub-scripts and one main
  script. This is the code from the main script:
 
  ?php
 
  include_once(sub_script_1.php);
  incude_once(sub_script_2.php);
 
  $temp = MyFunction();
 
  ?
 
  MyFunction() is contained in the file sub_script_1.php which is
properly
  enclosed with valid PHP start and end tags.
 
  But When I try to run the main script, I get this error:
  Fatal error: Call to undefined function: MyFunction()in /main_script.php
on
  line 4.
 
  How can I properly divide my script into several ones ???
 
  TIA,



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




Re: [PHP] include_once()

2002-03-19 Thread Mauricio Cuenca

No I haven't.

Wouldn't this affect my entire web site ?
I just need to include the files into a single script.

Thanks,
__
Mauricio Cuenca

- Original Message -
From: Neil Freeman
To: Mauricio Cuenca
Cc: [EMAIL PROTECTED]
Sent: Tuesday, March 19, 2002 12:30 PM
Subject: Re: [PHP] include_once()


 Have you remembered to set up PHP's include_path to point to the area
where
 your scripts are located?

 Neil

 Mauricio Cuenca wrote:

  Hello,
 
  I have a very long script with several functions in it. I wanted to
split
  the script into several files, so I created two sub-scripts and one main
  script. This is the code from the main script:
 
  ?php
 
  include_once(sub_script_1.php);
  incude_once(sub_script_2.php);
 
  $temp = MyFunction();
 
  ?
 
  MyFunction() is contained in the file sub_script_1.php which is
properly
  enclosed with valid PHP start and end tags.
 
  But When I try to run the main script, I get this error:
  Fatal error: Call to undefined function: MyFunction()in /main_script.php
on
  line 4.
 
  How can I properly divide my script into several ones ???
 
  TIA,
 



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




RE: [PHP] include_once()

2002-03-19 Thread Martin Towell

is it possible to send the code - or snippets of the code - so that someone
might be able to spot the error

something that you might want to look at is whether the included file has a
parse error - the set up in this company allows the parent script to
continue to run, even if the child script has an error (dunno if this is a
php setting or it's default behaviour???)

-Original Message-
From: Mauricio Cuenca [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 20, 2002 11:14 AM
To: anders nawroth; [EMAIL PROTECTED]
Subject: Re: [PHP] include_once()


Yes,

I read the documentation and took close note to include the start and end
tags... ?php  ?

Thanks,

__
Mauricio Cuenca

- Original Message -
From: anders nawroth 
To: Mauricio Cuenca f; [EMAIL PROTECTED]
Sent: Tuesday, March 19, 2002 2:26 PM
Subject: Re: [PHP] include_once()


 Have you put ?php   tags in your include-files?

 Anders

 - Ursprungligt meddelande -
 Från: Mauricio Cuenca 
 Till: 
 Skickat: den 19 mars 2002 17:43
 Ämne: [PHP] include_once()


  Hello,
 
  I have a very long script with several functions in it. I wanted to
split
  the script into several files, so I created two sub-scripts and one main
  script. This is the code from the main script:
 
  ?php
 
  include_once(sub_script_1.php);
  incude_once(sub_script_2.php);
 
  $temp = MyFunction();
 
  ?
 
  MyFunction() is contained in the file sub_script_1.php which is
properly
  enclosed with valid PHP start and end tags.
 
  But When I try to run the main script, I get this error:
  Fatal error: Call to undefined function: MyFunction()in /main_script.php
on
  line 4.
 
  How can I properly divide my script into several ones ???
 
  TIA,



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

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




[PHP] include_once vs require_once

2001-07-31 Thread mike cullerton

hey folks,

i'm wondering about the difference between include_once and require_once.
the manual says 

  The require_once() statement replaces itself with the specified file

  The include_once() statement includes and evaluates the specified file

so, what is the difference? it's almost like one is a copy/paste and the
other is some kind of read. is there any different behavior we should expect
in scripts using one method vs another.

my first guess was that require_once wouldn't evaluate the file, but i can
execute code from within a file using either method.

thanks,
mike


 -- mike cullerton



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] include_once

2001-02-28 Thread Hardy Merrill

Redhat 6.1 Linux
PHP 4.0.4pl1
Apache 1.3.14

Anyone using "include_once"?  I'm executing a PHP script "A.php"
by referring to it in my Netscape browser URL - script A.php does
an include_once of "B.php" - B.php contains a database connect
function that does a connect to an Oracle database.

I purposely brought down the Oracle database to force a connect
error.  I have an "error_log" statement in the connect failure
that prints to our webserver error log - the connect error was
reported fine.  ***THEN, I added more text to the error_log
output for that connect failure, but the new text is *NOT*
appearing in any subsequent connect failures.

Why won't my new text appear in the error?  I've tried changing
the "include_once" to "include", and the same thing happened.
I even tried restarting the webserver, but it had no affect.

This is driving me nuts!  Help please.

TIA.

-- 
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] include_once

2001-02-28 Thread Hardy Merrill

Solved - I was changing a copy of the code that the webserver
was NOT looking at.  "include_once" works fine.

Appologies.

-- 
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

Hardy Merrill [[EMAIL PROTECTED]] wrote:
 Redhat 6.1 Linux
 PHP 4.0.4pl1
 Apache 1.3.14
 
 Anyone using "include_once"?  I'm executing a PHP script "A.php"
 by referring to it in my Netscape browser URL - script A.php does
 an include_once of "B.php" - B.php contains a database connect
 function that does a connect to an Oracle database.
 
 I purposely brought down the Oracle database to force a connect
 error.  I have an "error_log" statement in the connect failure
 that prints to our webserver error log - the connect error was
 reported fine.  ***THEN, I added more text to the error_log
 output for that connect failure, but the new text is *NOT*
 appearing in any subsequent connect failures.
 
 Why won't my new text appear in the error?  I've tried changing
 the "include_once" to "include", and the same thing happened.
 I even tried restarting the webserver, but it had no affect.
 
 This is driving me nuts!  Help please.
 
 TIA.
 
 -- 
 Hardy Merrill
 Mission Critical Linux, Inc.
 http://www.missioncriticallinux.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]