Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cron Job issue: PHP Fatal error: Call to undefined function mysqli_connect()

Discussion in 'General Discussion' started by dr_lucas, Sep 21, 2017.

Tags:
  1. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    56
    I think this problem started just after I upgraded from EA3 to EA4, but can't be sure.

    My error_log shows this error:
    PHP Fatal error: Call to undefined function mysqli_connect() in...
    and
    PHP Fatal error: Call to undefined function mysql_connect() in...

    These errors are generated by 2 different cron jobs that I set on my cpanel account long ago and were working fine for years:
    First cron:
    Code:
    php /home/XXXXX/public_html/admin/YYYYY.php >/dev/null 2>&1
    
    and a similar one in the same directory.

    I logged in to shell as root (it's a dedicated centos 6.9 server with WHM 66.0.23), and ran the same command as the command written in the cron:
    Code:
    root@host [/]# php /home/XXXXX/public_html/admin/YYYYY.php
     
    #1 dr_lucas, Sep 21, 2017
    Last edited: Sep 21, 2017
  2. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    56
    ok, I did a bit more investigation and found out the cron is loading this configuration file:
    Code:
    /home/XXXXX/php.ini
    
    Instead of the configuration file Apache and litespeed are using:
    Code:
    /opt/cpanel/ea-php56/root/etc/php.ini
    
    Why does that happen and how can I fix it?
     
  3. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    56
    I might be wrong but it seems like some kind of a bug.
    There was a php.ini file in my user directory, as stated above, so cron was using it.
    I disabled the file by renaming it to
    /home/XXXXX/php.ini.bak
    Now everything works fine.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    It's possible you are noticing this issue due to a change in how php.ini files are managed. This is discussed in more detail on the following threads:

    SOLVED - cPanel 66 Update MultiPHP INI Editor Changes
    php.ini changes in cPanel 66

    Additionally, here's an example of how to use PHP in cron job commands:

    Thank you.
     
Loading...

Share This Page