Executing PHP gives error on command line interface, but works in browser

de Raad

Any idea what could cause a php file to execute fine in the browser, but give an error when run in the command line interface?

So to be specific, when I visit mysite.com/script.php in a browser, all is well.

When I execute php -f /var/www/mysite.com/public_html/script.php I get an error that one of my required files cannot be found.

So, the error message gives a lot of insight, but I am confused because it works as intended in the browser with no error, so I have no idea what could cause this behavior. Any ideas?

waltinator

By starting with ../, which is relative to the current working directory of the process, the require will only work if you are in the right directory. If you have control of the script, change it to use the full, absolute path starting at /,

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PHP works on command line but not in browser

From Dev

popen() in php works from command line but not from browser

From Dev

Executing gulp in php returns error but works in shell

From Dev

Error in executing Abaqus from command line

From Dev

Executing multiple line shell command in php

From Dev

Command Line PHP Script not executing correctly

From Dev

PHP executing background command line script

From Dev

command line argument in bash gives an error

From Dev

executing shell command in docker composer gives me error

From Dev

MySQL query runs fine in command line, but gives error when ran in php

From Dev

Bash syntax error executing command in Ruby, but it works in shell

From Dev

PHP TesseractOCR works only in command line

From Dev

PHP exec() works in command line but not in web

From Dev

PHP version - Command line vs Web browser

From Dev

Run php File in Browser from Command Line

From Dev

PHP-CPP new extension works on cli 'php' command but not in browser

From Dev

Gradle executing dex Error command line too long

From Dev

Error on executing steam proton app via command-line

From Dev

Error on executing Steam Play game via command-line (Proton)

From Dev

Error on executing steam proton app via command-line

From Dev

Error on executing Steam Play game via command-line (Proton)

From Dev

Java ClassNotFound error when executing via command line

From Dev

AWS: Command works in command line, but not PHP's exec

From Dev

Executing PHP file from command line with dynamic parameters

From Dev

laravel works on the php development server but on apache gives weird error

From Dev

Error in Running abaqus cae command from command line interface

From Dev

perl "kill 0" command works via .pl script, and command line, but not via browser

From Dev

Error executing command, exiting

From Dev

Error executing command, exiting

Related Related

  1. 1

    PHP works on command line but not in browser

  2. 2

    popen() in php works from command line but not from browser

  3. 3

    Executing gulp in php returns error but works in shell

  4. 4

    Error in executing Abaqus from command line

  5. 5

    Executing multiple line shell command in php

  6. 6

    Command Line PHP Script not executing correctly

  7. 7

    PHP executing background command line script

  8. 8

    command line argument in bash gives an error

  9. 9

    executing shell command in docker composer gives me error

  10. 10

    MySQL query runs fine in command line, but gives error when ran in php

  11. 11

    Bash syntax error executing command in Ruby, but it works in shell

  12. 12

    PHP TesseractOCR works only in command line

  13. 13

    PHP exec() works in command line but not in web

  14. 14

    PHP version - Command line vs Web browser

  15. 15

    Run php File in Browser from Command Line

  16. 16

    PHP-CPP new extension works on cli 'php' command but not in browser

  17. 17

    Gradle executing dex Error command line too long

  18. 18

    Error on executing steam proton app via command-line

  19. 19

    Error on executing Steam Play game via command-line (Proton)

  20. 20

    Error on executing steam proton app via command-line

  21. 21

    Error on executing Steam Play game via command-line (Proton)

  22. 22

    Java ClassNotFound error when executing via command line

  23. 23

    AWS: Command works in command line, but not PHP's exec

  24. 24

    Executing PHP file from command line with dynamic parameters

  25. 25

    laravel works on the php development server but on apache gives weird error

  26. 26

    Error in Running abaqus cae command from command line interface

  27. 27

    perl "kill 0" command works via .pl script, and command line, but not via browser

  28. 28

    Error executing command, exiting

  29. 29

    Error executing command, exiting

HotTag

Archive