I'm trying to run a cronjob in cPanel which gives me the following error:
Fatal error: Uncaught Error: Class 'mysqli' not found in /home/example/public_html/new_facebook_csv/csv_generator1.php:180
If run that file through browser by using the link example.com/new_facebook_csv/csv_generator1.php i get the right resaults without any errors, but if i try to run it with a cron job i get the error "Class 'mysqli' not found".
The cron job I'm running is the following:
php /home/example/public_html/new_facebook_csv/csv_generator1.php > /home/example/public_html/new_facebook_csv/facebook.log
and here is the logs i get after the cron job:
X-Powered-By: PHP/7.3.22
Content-type: text/html; charset=UTF-8
<br />
<b>Fatal error</b>: Uncaught Error: Class 'mysqli' not found in /home/example/public_html/new_facebook_csv/csv_generator1.php:180
Stack trace:
#0 {main}
thrown in <b>/home/example/public_html/new_facebook_csv/csv_generator1.php</b> on line <b>180</b><br />
I added the mysqli extension in the php.ini (extension=php_mysql.dll) but not luck with that.
Also check if mysqli is installed to my server with this commaned:
php -m|grep mysql
and that was my output
mysqli
mysqlnd
pdo_mysql
which means that mysql is installed to my server
try with curl like /usr/bin/curl example.com/new_facebook_csv/csv_generator1.php
or you can use wget wget -q -O- example.com/new_facebook_csv/csv_generator1.php
This is how I scheduled a cron job in cPanel through GoDaddy that runs the script and includes MYSQLI:
curl -s "https://yourwebsite.com/phpscript.php"
I tried many variations including cPanel's example on running a PHP script with a cron job. I tried php in front of the script path, and the same format you used above, as well as the suggested answers and I received the same errors. Just using curl -s and then the url of your php script will do the trick.
Related
I am using tomcat8.5, apache2, php7.25 on ubuntu 18.04
I installed php on my computer and did other configurations and installed required libraries. In the first day it worked fine and I could run a php script properly on localhost.
But next day when I tried to run the same php file I got this error.
Type Exception Report
Message Could not connect to server. Please start it with: cd /home/dr3am/Documents/phphome/WEB-INF/cgi/amd64-linux
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
php.java.fastcgi.ConnectionException: Could not connect to server. Please start it with: cd /home/dr3am/Documents/phphome/WEB-INF/cgi/amd64-linux
REDIRECT_STATUS=200 X_JAVABRIDGE_OVERRIDE_HOSTS="/" PHP_FCGI_CHILDREN="5" PHP_FCGI_MAX_REQUESTS="500" php-cgi -b 127.0.0.1:9669
php.java.fastcgi.SocketFactory.test(SocketFactory.java:73)
php.java.fastcgi.FCGIFactory.startFCGIServer(FCGIFactory.java:99)
php.java.fastcgi.FCGIConnectionPool.createConnectionPool(FCGIConnectionPool.java:147)
php.java.servlet.ContextLoaderListener.getConnectionPool(ContextLoaderListener.java:220)
php.java.servlet.ContextLoaderListener.getConnectionPool(ContextLoaderListener.java:209)
php.java.servlet.fastcgi.FastCGIServlet.doExecute(FastCGIServlet.java:374)
php.java.servlet.fastcgi.FastCGIServlet.execute(FastCGIServlet.java:468)
php.java.servlet.fastcgi.FastCGIServlet.handle(FastCGIServlet.java:479)
php.java.servlet.fastcgi.FastCGIServlet.doGet(FastCGIServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
java.net.ConnectException: Connection refused (Connection refused)
java.net.PlainSocketImpl.socketConnect(Native Method)
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
java.net.Socket.connect(Socket.java:607)
java.net.Socket.connect(Socket.java:556)
java.net.Socket.<init>(Socket.java:452)
java.net.Socket.<init>(Socket.java:262)
php.java.fastcgi.SocketFactory.test(SocketFactory.java:67)
php.java.fastcgi.FCGIFactory.startFCGIServer(FCGIFactory.java:99)
php.java.fastcgi.FCGIConnectionPool.createConnectionPool(FCGIConnectionPool.java:147)
php.java.servlet.ContextLoaderListener.getConnectionPool(ContextLoaderListener.java:220)
php.java.servlet.ContextLoaderListener.getConnectionPool(ContextLoaderListener.java:209)
php.java.servlet.fastcgi.FastCGIServlet.doExecute(FastCGIServlet.java:374)
php.java.servlet.fastcgi.FastCGIServlet.execute(FastCGIServlet.java:468)
php.java.servlet.fastcgi.FastCGIServlet.handle(FastCGIServlet.java:479)
php.java.servlet.fastcgi.FastCGIServlet.doGet(FastCGIServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs.
I didn't change any configuration file or removed any required library. But suddenly I got this error. I looked for solutions but I found nothing related to my problem.
What is the reason for this and how to solve it?
I have a PHP script that begins as follows:
#!/usr/local/bin/php -q
<?php
require_once 'vendor/autoload.php';
//set up google api client
$client = new \Google_Client();
When I execute directly from the command line using:
php /Users/xxxx/app.php
It executes normally. However when I include in crontab in the form:
30 7 * * * php /Users/xxxx/app.php
I get the following error:
Fatal error: Uncaught Error: Class 'Google_Client' not found in
/Users/xxxx/app.php:8
Stack trace:
#0 {main}
thrown in /Users/xxxx/app.php on line 8
I haven't used cron much previously - any idea how I might rectify this?
IMO the first thing to do is to use the complete path to the php executable and maybe also try setting the cronjob to run as the same user from when you execute from cli:
From cli run
which php
and insert the path in your cronjob (usually /usr/bin/php):
30 7 * * * YOUR_USER /PATH_TO_EXEC/php /Users/xxxx/app.php
I'm trying to run a script that imports data from an Oracle table into a Mysql table. I'm using oci_pconnect to connect to Oracle. Everything is running fine when the script is executed in the browser but i'm getting the following error when the script is run in cmd under Windows
Fatal Error: Call to undefined function oci_pconnect()
I'm calling the php script in cmd by the following code
#echo off
php C:\wamp\www\somefile.php
echo Done!
pause > nul
Thanks in advance!!
To avoid having this error, just go to php.ini located in your PHP folder and uncomment the line of the oci function in the extensions section:
;extension=php_oci8.dll
problem solved!
Using the following bits:
<?php
require('vendor/autoload.php');
$client = new Everyman\Neo4j\Client('localhost', 7474);
print_r($client->getServerInfo());
?>
If I run this as php test.php I get the expected output.
If I run this via http://server/test.php I get connection errors.
[24-Jun-2014 05:49:52] PHP Fatal error: Uncaught exception 'Everyman\Neo4j\Exception'
with message 'Can't open connection to http://localhost:7474/db/data/' in
/var/www/html/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Transport/Curl.php:91
Clearly I've monkeyed up something with either my PHP config or the installation of this library. Suggestions on where to look?
Installed per these instructions.
Running on CentOS 6.4 (x64), PHP 5.3.3
NOTE: I've made successful connections from other machines back to this server so I know the neo4j server is working. It just doesn't seem to want to let me connect locally when called via browser.
I had same issue, it was caused by SeLinux
Try disabling it by:
echo 0 >/selinux/enforce
then recheck connection.
If solved configure SeLinux permissions.
In my case httpd_can_network_connect should be on
setsebool -P httpd_can_network_connect on
echo 1 >/selinux/enforce
Helpful manual:
http://wiki.centos.org/TipsAndTricks/SelinuxBooleans
I have been trying to convert an html page to PDF with out any luck, I have tried to use wkhtmltopdf (http://code.google.com/p/wkhtmltopdf/) and the PHP class provided by the same developers (http://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp) although the following command executed correctly in terminal:
wkhtmltopdf http:/www.googl.com test.pdf
I was unable to execute the command in PHP because of the following error:
cannot connect to X server.
Can any one provide me with a step-by-step tutorial in order to be able to convert html/css to PDF file, whether using wkhtmltopdf or any other decent solution.
Thanks in advance
here is the class that i have used http://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp
and below is my code
$html = file_get_contents("test.html");
$pdf = new WKPDF();
$pdf->set_html($html);
$pdf->render();
$pdf->output(WKPDF::$PDF_EMBEDDED,'sample.pdf');
Below is the error:
Fatal error: Uncaught exception 'Exception' with message 'WKPDF didn't return any data.
/usr/bin/wkhtmltopdf: /opt/lampp/lib/libxml2.so.2: no version information available
(required by /usr/lib/libgstreamer-0.10.so.0) No protocol specified wkhtmltopdf: cannot
connect to X server :0 </pre>' in /var/www/c4/components/com_wkhtmltopdf
/wkhtmltopdf.class.php:211 Stack trace: #0 /var/www/c4/components/com_wkhtmltopdf
/wkhtmltopdf.php(68): WKPDF->render() #1 /var/www/c4/components/com_wkhtmltopdf
/wkhtmltopdf.php(50): html2pdf() #2 /var/www/c4/index2.php(114): require_once('/var/ww...')
#3 {main} thrown in /var/www/c4/components/com_wkhtmltopdf/wkhtmltopdf.class.php on line 211
I found the solution, The following error "No protocol specified wkhtmltopdf: cannot
connect to X server :0" was basically caused by on old version of "wkhtmltopdf" which was installed using apt-get. The solution was to download the static binary from the code.google using the following link:
http://code.google.com/p/wkhtmltopdf/downloads/list
and then perform the following actions:
tar -jxvf wkhtmltopdf-0.11.0-static.tar.bz2
sudo aptitude install ia32-libs
Next, you’ll have to make a symbolic link pointing to WKHTMLTOPDF in /usr/bin.
sudo ln -s /full_path/WKHTMLTOPDF /usr/bin/WKHTMLTOPDF