I have a cron job that runs daily (for over a year) and suddenly does not work.
I have a cron job that looks like:
/usr/bin/php -q /home/tcanfarotta22/public_html/test_arg.php low_customer=2 high_customer=200
And then a PHP script that gets the variables like:
parse_str($argv[1], $params);
parse_str($argv[2], $params2);
$low_customer = $params['low_customer'];
$high_customer = $params2['high_customer'];
Now I am getting the following errors:
[18-Jun-2018 10:38:01 America/New_York] PHP Notice: Undefined
variable: argv in /home/tcanfarotta22/public_html/test_arg.php on line
5 [18-Jun-2018 10:38:01 America/New_York] PHP Notice: Undefined
variable: argv in /home/tcanfarotta22/public_html/test_arg.php on line
6 [18-Jun-2018 10:38:01 America/New_York] PHP Notice: Undefined
index: low_customer in /home/tcanfarotta22/public_html/test_arg.php on
line 8 [18-Jun-2018 10:38:01 America/New_York] PHP Notice: Undefined
index: high_customer in /home/tcanfarotta22/public_html/test_arg.php
on line 9
Nothing has changed so I ma not sure what to do. Does anyone know?
If the enabling of register_argc_argv does not fix the issue, then maybe you are trying to access $argv within a class, in this case, you need to declare it as global before you can access it:
global $argv;
BTW, I have tested your code (executed by the terminal) and it runs like a charm.
If this does not fix the issue, maybe then you need to put more details, also we need to know how you are testing?
Related
I have to run a php file every 5 seconds , and have two issues
1. The file works perfectly when opened in a browser, but running the 'php myfile.php' command fails and produces the following error
PHP Warning: include_once(../tutadmin/config/config.php): failed to open stream: No such file or directory in /var/www/html/cron/teacher_status_cron.php on line 3
PHP Warning: include_once(): Failed opening '../tutadmin/config/config.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/cron/teacher_status_cron.php on line 3
PHP Notice: Use of undefined constant TBL_USER - assumed 'TBL_USER' in /var/www/html/cron/teacher_status_cron.php on line 5
PHP Notice: Use of undefined constant TEACHER_USER_GROUP_ID - assumed 'TEACHER_USER_GROUP_ID' in /var/www/html/cron/teacher_status_cron.php on line 9
PHP Notice: Undefined variable: current_user_id in /var/www/html/cron/teacher_status_cron.php on line 14
PHP Notice: Undefined variable: current_date_time in /var/www/html/cron/teacher_status_cron.php on line 15
PHP Notice: Undefined variable: dbc in /var/www/html/cron/teacher_status_cron.php on line 20
PHP Fatal error: Uncaught Error: Call to a member function Query() on null in /var/www/html/cron/teacher_status_cron.php:20
Stack trace:
#0 {main}
thrown in /var/www/html/cron/teacher_status_cron.php on line 20
Crontab will not run the program every 5 seconds, only every minute at best.
Edit: the file does not work outside of cron in the CLI either, only on a web browser.. Cron is not the issue.
Because you have not right permissions on file, your cron can not open file, change permissions.
I'm trying to set up WordPress on my laptop running Kali Linux. Everything works until I install WordPress and the theme I am using. I'm trying to use roots sage on bedrock. But after I get through the installation process I get a notice in the admin:
Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2937
Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2937
Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2999
Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2999
And in the frontend:
Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2999
Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2999
Can anyone explain why I'm getting these notices? I must have missed something but I've gone through the instructions several times and I'm out of ideas. Thanks
You can define WP_HOME & WP_SITEURL in wp-config.php
define('WP_HOME','http://localhost/project_folder_name');
define('WP_SITEURL','http://localhost/project_folder_name');
This can also be caused by an error with the siteurl and home options in wp_options table.
Make sure the url's have a host as well, http://example.com not just example.com.
I just now came across this and for me, switching back from PHP 8.x.x to PHP 7.x.x resolved the issue.
find i m trying to convert sequence of images into a video. and for that i canme to know about the ffmpeg class.
the only wrapper class that i found is phpvideotoolkit but i m not able to work with it.
i installed phpvideotoolkit on xampp on my windows 2008 server . but it is throwing alor of errors
This example shows you how to extract a specific frame from a movie.
Notice: Undefined property: PHPVideoToolkit::$_tmb_directory in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 869
Notice: Undefined offset: 0 in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 877
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\to-be-processed\MOV00007.3gp" was not found. No images were generated.
Notice: Undefined property: PHPVideoToolkit::$_tmb_directory in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 869
Notice: Undefined offset: 0 in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 877
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\to-be-processed\Video000.3gp" was not found. No images were generated.
Notice: Undefined property: PHPVideoToolkit::$_tmb_directory in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 869
Notice: Undefined offset: 0 in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 877
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\to-be-processed\cat.mpeg" was not found. No images were generated.
example
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\tmp\1336156630-4fa421d69357d\tmp_%d.jpg" was not found. Please check server write permissions and/or available codecs compiled with FFmpeg. You can check the encode decode availability by inspecting the output array from PHPVideoToolkit::getFFmpegInfo().
i m trying to make it work since last many hours but no luck
Also, for this code :
$srcFile = "test-mpeg.mpg";
$ffmpegObj = new ffmpeg_movie($srcFile);
i am gettign error that it cant file the file. i believe its something to do with permissions but i m not able to figure out
fpoen , fwrite , file_put_contents all are working fine without any permissions problems.
can anyone please guide me in the write direction. what do i need to do to make this phpvideotoolkit work
For an example:
php.ini file
...
; Log errors to specified file.
error_log = c:/php/php.log
...
Error log file (c:/php/php.log) contains every entry in this format:
[12-Jun-2011 12:58:55] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 12:59:01] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:01:12] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:02:11] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:11:23] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:12:10] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
Two carriage return character and one new line per one error line.
Why it happens?
How to change error log file to default format:
[12-Jun-2011 12:58:55] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 12:59:01] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:01:12] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:02:11] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:11:23] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:12:10] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
PHP Version 5.3.6
Apache/2.2.15 (Win32)
Tested on Windows 7 Home Basic and Windows XP SP3, same results.
php.ini file contains only two strings
log_errors = On
error_log = c:/server/php.log
apache phpinfo() script -> http://pastehtml.com/view/awvx1vgpp.html
PS.
sever: nginx 1.0.4
FastCGI + PHP Version 5.3.6
Everything works as expected.
nginx phpinfo() script -> http://pastehtml.com/view/awvwvk9p9.html
There are more ini directives to control the output into the error log. These are explained on this PHP manual page.
By default, PHP running with not loading the ini and only having the error_log set and logging enabled, it does output a single line only. You can test that on your system as well, it demonstrates it well for the Command Line Interface (CLI) "Server Application Programming Interface (API) [SAPI]":
php -n -d error_log=./error.log -d log_errors=1 -r 'error;'
Use this command to make an isolated run and compare it with your output. If it has two line endings as well, then this is probably a bug of your php version.
If not a problem with the PHP version [not the case in the original posting (OP)] then within your application some settings looks to be altered. You need to find out which setting. Probably you can find it by registering an own error handler and then dumping the ini settings.
Last but not least, if it isn't a misunderstanding of the line ending (see my comment), then one may want to also look in the ini settings named error_prepend_string and error_append_string regarding the error display (but not the error logging).
I'm trying to get the Ansinerator library to work my on my localhost, but something's amiss.
I'm receiving the following errors:
Notice: Undefined index: hash in ansi.php on line 23 Notice: Undefined index: aml in ansi.php on line 37 Notice: Undefined variable: PNG_DESTRUCT in ansi.php on line 119 Notice: Undefined offset: -1 in ansi.php on line 362 Notice: Trying to get property of non-object in ansi.php on line 362 Notice: Undefined variable: links in ansi.php on line 459 Notice: Trying to get property of non-object in ansi.php on line 677 Notice: Undefined variable: links in ansi.php on line 459 Notice: Undefined variable: map_link in ansi.php on line 687
Any idea where am I going wrong with this one? I've installed the php-gd library, restarted the server, and while runs perfectly on production server, localhost will refuse. Ideas?
Thank you.
Check
- That you've got 'proper' versions of everything installed on localhost. (Compare localhost with production.) There's obviously something different between the 2 servers here, just use phpinfo() to check.
Restart localhost again? (Just kidding...)
Is it possible that you have set different error reporting levels on both servers?
Before anything, put error_reporting(E_ALL); at the top of your script on both servers and see if it runs perfectly. (My guess is you will get errors on both servers)