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!
Related
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.
The php function yaml_emit_file() is not working. I have installed and included the php_yaml.dll in my php.ini file restarted the server but still when I use this function, I get this error (when I run composer):
Call to undefined function RS\composer\yaml_emit_file()
Okay so a little about the background:
PHP version 7.1.7 & Composer version 1.5.1
I am using this function in a ScriptHandler.php file which is invoked when Composer is run. In this script I have a function buildModuleList which is called on post-update-cmd event of Composer. Everything else in the code is working fine.
I am in doubt that maybe I am using this function in wrong context or something like that.
Here is the code snippet where I am using yaml_emit_file() (Providing this just for reference, tell me if am using it the wrong way!):
if (!$fs->exists($moduleListFile)) {
$fs->touch($root.'/profiles/thunder/modulelist.yml');
$fs->chmod($root . '/profiles/thunder/modulelist.yml', 0666);
if(!empty($moduleList)){
$createyml= yaml_emit_file($moduleListFile, $moduleList);
if (!$createyml){
$io->writeError('<error>Cannot create modulelist.yml</error>');
}
}
$io->write('Success: Created new modulelist.yml', $newline= TRUE);
}
else{
$fs->file_put_contents($moduleListFile, $installedPackage, FILE_APPEND);
$io->write('Success: Module entry in modulelist.yml', $newline= TRUE);
}
i hope this help someone i test it on
Windows 10
XAMPP v3.2.4
PHP 8.0.2
Download the latest YAML DLL Package from : https://pecl.php.net/package/yaml
Unzip the files
Move the php_yaml.dll file to xampp/php/ext folder
Open your php.ini in xampp/php add a new line extension=php_yaml.dll, save and exit
Restart your XAMPP Servers
make a PHP file put into
<?php
phpinfo();
?>
Search the string yaml on the page. If it says Enabled then your YAML Extension is working.
I am able to run it through the browser but not from command line
ie php test.php
$raw = Cassandra::cluster()
->withContactPoints('localhost')
//->withCredentials($this->username, $this->password)
->build();
var_dump($raw);
die;
from browser:
object(Cassandra\DefaultCluster)#2 (0) { }
command line:
PHP Fatal error: Class 'Cassandra' not found in /var/www/html/test.php on line 2
Is it possible to get same from command line as well?
The cli uses a different php.ini file (e.g. /etc/php/7.0/cli/php.ini & /etc/php/7.0/fpm/php.ini). You are probably not including the extension in the cli one.
I have standard setup for Ispconfig 3:
https://www.howtoforge.com/perfect-server-debian-wheezy-apache2-bind-dovecot-ispconfig-3
Server is up to date. Everything working fine.
I'm trying to add PHP 5.6.12 following this guide:
https://www.howtoforge.com/how-to-build-php-5.6-fpm-fastcgi-with-zend-opcache-and-apcu-for-ispconfig-3-on-debian-7-wheezy
Everything went ok until start fpm:
/etc/init.d/php-5.6.12-fpm start
Starting php-fpm [02-Sep-2015 18:16:07] ERROR: [/opt/php-5.6.12/etc/php-fpm.conf:540] value is NULL for a ZEND_INI_PARSER_ENTRY
[02-Sep-2015 18:16:07] ERROR: failed to load configuration file '/opt/php-5.6.12/etc/php-fpm.conf'
[02-Sep-2015 18:16:07] ERROR: FPM initialization failed
failed
Problem is when this line is inserted at the end of /opt/php-5.6.12/etc/php-fpm.conf:
include /opt/php-5.6.12/etc/pool.d/*.conf
If I comment this line, fpm starts, but new PHP version in ISPconfig doesn't work.
I found this solution:
serverfault.com/questions/547394/is-there-a-limit-setting-a-php-admin-value-in-php-fpm
and used this fix:
github.com/DaveRandom/php-src/commit/9ad8e89d4f080626a92fc8817ab156c09b6b266a
and compiled again with it. Same result.
Any clue? Please help.
I ran into the same problem today, you need an = just after include
hi i'am using phpunit with selenium webdriver.
when i make this cmd
phpunit myfile
i get this error message
Call to undefined function curl_init().4.3\pear\PHPUnit\Extensions\Selenium2TestCase\Driver.php
my code is
<?php
class WebTest extends PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl('http://www.google.com/');
}
public function testTitle()
{
$this->url('http://www.google.com/');
$this->assertEquals('google', $this->title());
}
}
?>
some says to check my curl i have to cmd this
php --ini
but the response outed in many line ,there are some line outed before but hidden
how te see the previous line on the DOS ?
Enable curl by clicking on wamp server icon on the task bar and click php then select php extension and select curl and also verify that u have this line in your php.ini
php extension=php_curl.dll
for more refer this php.net/manual/en/book.curl.php
Remember that phpunit is probably run in the command line and the command line uses a different php.ini
If you want to find out, which one would be the correct php.ini, just run this command in the command line:
php -i | find /i "Configuration File"
I solved the problem by copying php.ini from apache to my php folder.