Page 1 of 1

include paths

Posted: Tue Apr 26, 2005 5:34 am
by dannymc1983
im trying to run a php script that will work fine when i try to run it in a browser but wont recognise the include paths when i run in on the command line for some reason. (the program has to run on the command line because its part of a cron job)

heres just a simplified example of what im trying to do:
i have a file called test1.php in one directory called test1
i have another file called test2.php in another directory called test2

in test1.php i have the include path "include_once ('../test2/test2.php');
now if im right file test2.php should be included in test1.php

if i run test1.php in the browser it works fine. however, if run it on the command line using the following command: "c:\wamp\php\php.exe -c c:\wamp\apache\php.ini -q c:\wamp\www\test1\test1.php"
i get an error saying that it failed to open ../test2/test2.php in c:\wamp\www\test1\test1.php.

if i take the include path out of test1.php and run it in the command line, test1.php executes perfectly so i know its not a problem with the command im using

anyone know how to fix this??? im using windows, dunno if that effects include paths or not...

Posted: Tue Apr 26, 2005 5:38 am
by n00b Saibot
I haven't had any such probs so just a guess. change the path to '..\\test2\\test2.php' and see what happens :!:

Posted: Tue Apr 26, 2005 5:43 am
by dannymc1983
nope, didnt work...

Posted: Tue Apr 26, 2005 5:55 am
by n00b Saibot
Does giving absolute path solves the matter :?:

Posted: Tue Apr 26, 2005 6:02 am
by phpScott
is it something that you will have to run both from the command line and the browser or just the command line in your cron job?

if it is just part of the cron job you should be able to

Code: Select all

include('c:\wamp\www\test2\test2.php')

Posted: Tue Apr 26, 2005 6:09 am
by dannymc1983
ya its something that needs to run in both command line and the window so i dont want to use any full directory paths in the include paths...
any other ideas? i cant understand why the paths are recognised in the browser and not in the commnad line. dont they use the same php engine??