Montha Posted May 26, 2022 Share Posted May 26, 2022 Hi, to all. I've a code typed in php on my index.php, that code calls another file engine.php that is in another sub directory, that file reads a directory searching for *.txt, open each file and search/count for a xml label and show the results. The problem is that when i execute the engine.php from the directory /process (in this directory i store all my functions) the code doesn't execute correctly, but when i move the engine.php to the directory where the files to count are it executes and shows all the information correctly. What could be the problem? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/314840-script-doesnt-run-ok-when-is-executed-from-another-folder/ Share on other sites More sharing options...
gizmola Posted May 26, 2022 Share Posted May 26, 2022 We are not psychic. Most likely you have a pathing problem with your code. Paste relevant portions or the script in its entirety so that we can see what you've done. Make sure to use the code button <> when you paste the code so formatting is preserved. Quote Link to comment https://forums.phpfreaks.com/topic/314840-script-doesnt-run-ok-when-is-executed-from-another-folder/#findComment-1596694 Share on other sites More sharing options...
schwim Posted May 26, 2022 Share Posted May 26, 2022 5 hours ago, Montha said: The problem is that when i execute the engine.php from the directory /process (in this directory i store all my functions) the code doesn't execute correctly, but when i move the engine.php to the directory where the files to count are it executes and shows all the information correctly. What could be the problem? If you're using relative paths in engine.php and calling that file directly, moving it to a subdir will break the includes. In your example, if engine.php needed functions.php, in root it would look like include('./includes/functions.php'); the single dot meaning start in the current directory whereas, if it were in /process, it would look like include('../includes/functions.php'); the two dots meaning move up to the parent directory. Share your directory structures and include code for more relevant suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/314840-script-doesnt-run-ok-when-is-executed-from-another-folder/#findComment-1596706 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.