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!

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 Well-Known Member

    Joined:
    Jul 6, 2007
    Messages:
    47
    Likes Received:
    1
    Trophy Points:
    58
    Location:
    Thailand
    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 Well-Known Member

    Joined:
    Jul 6, 2007
    Messages:
    47
    Likes Received:
    1
    Trophy Points:
    58
    Location:
    Thailand
    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 Well-Known Member

    Joined:
    Jul 6, 2007
    Messages:
    47
    Likes Received:
    1
    Trophy Points:
    58
    Location:
    Thailand
    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 Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,442
    Likes Received:
    1,962
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice