PHP: mysql_connect() won't work via command line

后端 未结 7 1832
情书的邮戳
情书的邮戳 2021-01-17 15:37

I have a script which calls mysql_connect() to connect to a MySQL DB. When I run the script in a browser, it works. However, when I run it from a command line

相关标签:
7条回答
  • 2021-01-17 16:02

    It maybe using a default PHP configuration. I have found before that it doesn't use the same php.ini or doesn't use one at all. Therefore some of the extensions won't be enabled.

    Do this instead:

    php -c /etc/php.ini /path/to/script.php
    

    Where /etc/php.ini is the path to your ini file. You can find this by doing a phpinfo();

    0 讨论(0)
提交回复
热议问题