I am moving my site from linux shared hosting to cPanel hosting. I have several php scripts to access sql database and others which get information from other sites using json. A new database is up and running on the cPanel server. I have currently have 2 problems with php.
1. Call to undefined function json_decode() The line reporting the error is: $theFeatures->parsed_json = json_decode($theFeatures->json_string);
2. Class 'mysqli' not found. The line reporting the error is: $conn = new mysqli(HOST_NAME, USER_NAME, PASSWORD, NEWFOUND_DATABASE);
I have tried cPanel "Select PHP Version" switching from 7.1 to all lower versions with no success. In all php versions selected json and mysqli are checked.
Shared site is : newfoundlakeweather.com
cPanel site is : migrate.newfoundlakeweather.com
Any suggestions would be appreciated
Hey, i have a python 3 script which need pymysql, request and json libs, but crontab error log shows that all these library are missing, so how can i install them.
I have a linux shared hosting, please response asap
OK, so i found the answer, json and requests lib are already present and instead of using pymysql one can use python-mysql here is an example : python example
Would you help? I am also having similar issue. Godaddy shared linux environment runs python 2.4 which doesn't seem to have json. How do I import json, or even simplejson library? You say json libraries are present but I don't think so.
I'm having the same issue with json:
[12-Dec-2017 10:10:13 UTC] PHP Fatal error: Uncaught Error: Call to undefined function json_decode() in /home/
Json in PHP modules selectors is on. How come we have not got this fixed yet?
It sounds like you just need to activate json and mysqli. If you go back into where the php version selector was, you will see an option on the top right that reads Switch to PHP options. If you click on this, you will see the options listed for the different php modules. Make sure you have mysqli and json checked.
Hope this helps!
Having same problem. The only PHP version that has working JSON and PDO is 5.4 native. All the configurable options (5.4, 5.5, 5.6, 7.0, 7.1) fail to find JSON and PDO functionality.
Doing a phpinfo() shows on 5.4 native
json and pdo enabled as shared with the following under the configuration section.
PDO PDO support enabled
|PDO drivers||mysql, sqlite|
pdo_mysql PDO Driver for MySQL enabled
|Client API version||mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $|
Directive Local Value Master Value
pdo_sqlite PDO Driver for SQLite 3.x enabled
But on 5.4, 5.5, 5.6, 7.0, and 7.1 (where modules are configureable) the "Configure Commands" are shown for json, pdo, with-pdo-sqlite, with-pdo-pgsql, with-pdo-dblib, with-pdo-firebird, and with-pdo-odbc. However, they don't ever seem to be loaded under the configuration section. Aside from that I have pdo_mysql checked in the module options for each PHP version, but it never showed up in the "Configure Commands" or in the configuration section.
I'm having the same issue in that the PDO module (enabled in the PHP extensions section of cPanel) does not work using any of the PHP versions available (including native) even though the requisite PDO modules are checked (enabled). This was working up until December but it no longer works. When I run a script that includes a call to PDO (for connecting to a MySQL database), I get the error:
Fatal error: Class 'PDO' not found in /path/to/file.php on line 7
(PHP 7.x also then gives the stack trace). If I log into my account via SSH and run the script from the PHP CLI, it works without issue and updates the database as expected so the code is fine (and was working previously) but always errors when called via HTTP/HTTPS.
Any help would be most appreciated.
In case anyone runs into this issue, my problem was my account was migrated from a legacy account to cPanel hosting and the php.ini file in my local www folder was pointing to an outdated extensions_dir so PHP wasn't;t finding the PDO extensions. Removing the extensions_dir entry from my local php.ini file corrected the issue and PDO now works fine to connect to my MySQL databases.