Jump to content

PHP, crontab & mysqli fatal error


kama

Recommended Posts

Hi

 

I've been setting up a crontab today and I'd really appreciate a little help with this error I've come across...

 

I currently have a crontab set up (working fine) to send any output to my email address and this is what it's giving me:

'Fatal error: Class 'mysqli' not found in /my/php/script.php on line #'

 

This script works absolutely perfectly from the browser, and I've looked around online and haven't found any advice I can match to this problem. How do I make the script find mysqli when executed from crontab?

 

Many thanks for any help.

 

Kama

Link to comment
https://forums.phpfreaks.com/topic/155081-php-crontab-mysqli-fatal-error/
Share on other sites

Probably you have to add a parameter to load your php.ini (so that mysqli and other extensions are loaded)

http://www.php.net/features.commandline

 

its possible that you are using 2 different php.ini files one for the Apache server, and one for your cron's.

Probably you have to add a parameter to load your php.ini (so that mysqli and other extensions are loaded)

http://www.php.net/features.commandline

 

its possible that you are using 2 different php.ini files one for the Apache server, and one for your cron's.

 

As far as I can tell (and I am new to a lot of this) there are 2 php.ini files - and having checked they are basically identical.  I think I'm right in saying that when executing a php script in shell it uses the path/to/php/cli/php.ini which does contain all the mysqli settings.

 

Thanks for your help - any more ideas appreciated!

 

Kama

Run php --ini  to see what and if any ini files are loaded.

 

I tried this but nothing happened, so I looked it up and it only works as of PHP 5.2.3 - apparently I have 5.1.2 installed on the server.

I tried php -i |grep php.ini instead and it gave me the ini file I've been looking at: /path/to/php/cli/php.ini

 

Should this ini file be set up exactly the same as the ini file used for web output?

 

is the mysqli extension enabled?

 

Ohhh! I've just enabled it and everything seems to be working OK.

Can I just ask though... I can run my script via a browser and it works, yet there's no extension=mysqli.so line in the cgi/php.ini - that's why I assumed mysqli must already be enabled in the cli/php.ini file, because they're both identical.  Can you tell me why then I had to add the line to cli/php.ini for the script to work!?  What's so different about running php scripts via the web that means the extension=mysqli.so line isn't necessary?

 

Thanks for all your help on this...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.