Forum Moderators: coopster

Message Too Old, No Replies

odd problem: my script doesn't obbey a require once('foo.php')

foo.php works in commandline, but not with require_once

         

guarriman

6:21 pm on May 11, 2007 (gmt 0)

10+ Year Member



Hi.

I've got two scripts: 'main.php' and 'foo.php'.

main.php:


print "hello";
require_once('foo.php');
print "bye";

foo.php


print "this is foo.php";

If I execute (via shell):
# php main.php
it works fine

If I execute
# php foo.php
it works fine

But If I access http://example.com/main.php,
I get "hello" and "bye", but not "This is foo.php"

Any similar experience?

[edited by: eelixduppy at 8:36 pm (utc) on May 11, 2007]
[edit reason] example.com [/edit]

jatar_k

6:50 pm on May 11, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



maybe a bad path?

from that example foo.php and main.php should be in the same dir, are they?

do you have display_errors turned off? maybe it's dying and you just aren't seeing the errors.

guarriman

9:44 am on May 14, 2007 (gmt 0)

10+ Year Member



I fixed it by changing 'foo.php' call with 'foo1.php' call (and creating a copy of 'foo.php' in 'foo1.php').

It's very very odd but it works.

main.php, foo.php and foo1.php are in the same directory.

whoisgregg

2:21 pm on May 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably a permissions issue. Pretty sure that when you run the command line, the script has the permissions of the user who executed the script. When you load a webpage, the script has the permissions of the much less privileged web user (typically apache or www).