include paths

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dannymc1983
Forum Commoner
Posts: 80
Joined: Wed Feb 16, 2005 7:24 am

include paths

Post 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...
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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 :!:
dannymc1983
Forum Commoner
Posts: 80
Joined: Wed Feb 16, 2005 7:24 am

Post by dannymc1983 »

nope, didnt work...
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Does giving absolute path solves the matter :?:
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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')
Last edited by phpScott on Tue Apr 26, 2005 6:14 am, edited 1 time in total.
dannymc1983
Forum Commoner
Posts: 80
Joined: Wed Feb 16, 2005 7:24 am

Post 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??
Post Reply