kama Posted April 21, 2009 Share Posted April 21, 2009 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 More sharing options...
Mchl Posted April 21, 2009 Share Posted April 21, 2009 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 Link to comment https://forums.phpfreaks.com/topic/155081-php-crontab-mysqli-fatal-error/#findComment-815706 Share on other sites More sharing options...
The Little Guy Posted April 21, 2009 Share Posted April 21, 2009 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. Link to comment https://forums.phpfreaks.com/topic/155081-php-crontab-mysqli-fatal-error/#findComment-815792 Share on other sites More sharing options...
kama Posted April 22, 2009 Author Share Posted April 22, 2009 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 Link to comment https://forums.phpfreaks.com/topic/155081-php-crontab-mysqli-fatal-error/#findComment-816172 Share on other sites More sharing options...
Mchl Posted April 22, 2009 Share Posted April 22, 2009 Run php --ini to see what and if any ini files are loaded. Link to comment https://forums.phpfreaks.com/topic/155081-php-crontab-mysqli-fatal-error/#findComment-816324 Share on other sites More sharing options...
kama Posted April 22, 2009 Author Share Posted April 22, 2009 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? Link to comment https://forums.phpfreaks.com/topic/155081-php-crontab-mysqli-fatal-error/#findComment-816610 Share on other sites More sharing options...
Mchl Posted April 22, 2009 Share Posted April 22, 2009 Not necessarily. You're not running your web pages using CLI. Just make sure you have extensions you need enabled in it. Link to comment https://forums.phpfreaks.com/topic/155081-php-crontab-mysqli-fatal-error/#findComment-816642 Share on other sites More sharing options...
kama Posted April 22, 2009 Author Share Posted April 22, 2009 As far as I can tell both php.ini files are identical and all the same extensions are enabled in both. This really isn't my area, but could it be that something was missed when compiling php? Link to comment https://forums.phpfreaks.com/topic/155081-php-crontab-mysqli-fatal-error/#findComment-816879 Share on other sites More sharing options...
The Little Guy Posted April 22, 2009 Share Posted April 22, 2009 is the mysqli extension enabled? Link to comment https://forums.phpfreaks.com/topic/155081-php-crontab-mysqli-fatal-error/#findComment-816913 Share on other sites More sharing options...
kama Posted April 23, 2009 Author Share Posted April 23, 2009 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... Link to comment https://forums.phpfreaks.com/topic/155081-php-crontab-mysqli-fatal-error/#findComment-817122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.