Manual php script execution works while execution via debian fails - php

I have a problem with running the script using scheduled cron jobs. The thing is that when I run the php script using the browser it is executed without any problems/failures etc.
But when I try to run it using crons or SSH I get weird errors:
Notice: Undefined index: HTTP_USER_AGENT in /home/loves/public_html/parser/shop_parse_class.php on line 125
PHP Notice: Undefined offset: 0 in /home/loves/public_html/parser/shop_parse_class.php on line 481
PHP Notice: Undefined offset: 1 in /home/loves/public_html/parser/shop_parse_class.php on line 482
PHP Notice: Undefined variable: cat in /home/loves/public_html/parser/shop_parse_class.php on line 538
As you can see from the errors it shows that, for example the option HTTP_USER_AGENT doesn't exist for the CURL, which is kinda weird. Maybe the problem is with the environment variables, however I have poor knowledge of linux system.

You should add the -A or --user-agent parameter to the cURL call.
You can set anything you want as user agent this way.

HTTP_USER_AGENT is a information returned by the browser, if you are running like a script, you can't use this array. Is that reason the array is empty (the message tells that the index you trying to use in array don't exists)

Related

PHP scripts not working after migrating to PHP7

After migrating to PHP7.2 from PHP5.5 , my PHP scripts are not getting executed however phpinfo() is loading fine . I have installed php from source code .
I have enabled display_errors setting and it showing the following messages
[03-Oct-2018 16:32:12 UTC] PHP Warning: Creating default object from empty value in config.php on line 163
[03-Oct-2018 16:32:12 UTC] PHP Notice: Array to string conversion in get.php on line 25
[03-Oct-2018 16:32:12 UTC] PHP Notice: Undefined property: stdClass::$Array in get.php on line 25
But these are warnings and notices .
Am I missing some configuration to make the code work ?
On the first error in config.php file, you probably should instantiate a new stdClass() like the example below:
$var = new stdClass()
and then assign a value to its properties.
On the second error, you must have assigned the var as an array and then trying to echo that var
Without seeing the code I think its all the help I could give you

Why localhost react different compare to server in PHP programing

My question is look like duplicate but it is not.
Error like
Notice: Constant BASE_URL already defined in
Notice: Undefined variable: nomobile in
Notice: Constant imagesize already defined in
Notice: A session had already been started - ignoring session_start() in
But there is no problem in server. and i am using
PHP version: 5.6.30 both side.
This is error disable in server so server cannot show error.
For more information

Nusoap Undefined index in nusoap.php on line

I'm trying to call my WS from my device, but I get this error:
PHP Notice: Undefined index: in C:\wamp64\www\gcm\lib\nusoap.php on line 6637
But, when I test the WS from SOAPUI I get the correct result:
Any solution?
as per your statement, that is not an error. it is just a notice, you can ignore that.
disable php errors by error_reporting(0) and check

How to generate a sitemap for my MediaWiki wiki family?

I am well aware of the existence of the maintenance script generateSitemap.php. I got a unique multi-language wiki setup though. That is i guess why it does not really work.
So after i do php -f generateSitemap.php i get this error:
PHP Warning: file_get_contents(/var/www/mySite/_inc/../.ENVIRONMENT): failed to open stream: No such file or directory in /var/www/mySite/_inc/settings.inc.php on line 12
PHP Notice: Undefined index: HTTP_HOST in /var/www/mySite/wiki/LocalSettings.php on line 174
<br />
<b>Notice</b>: Undefined index: HTTP_HOST in <b>/var/www/mySite/wiki/LocalSettings.php</b> on line <b>174</b><br />
DB connection error: Connection refused (127.0.0.1:8889)
I got ONE single LocalSettings.php and only ONE database using prefixes. It changes depending on the user language like or what he/she selects so:
de.mySite.org
en.mySite.org
es.mySite.org
and so forth.
How can i run my maintenance script and get my sitemap? Any ideas are welcome.
Edit:
I tried setting different parameters as shown here. I did not get it right yet.
Edit2:
I plan to use a Cron to update sitemap automatically via a bash command.

Error in MenuHelper after copying htdocs folder to other server

I just copied my htdocs folder to anther pc with a clean new xampp and made a copy of the database too. When i try to access the site the php error log shows this error:
[13-Jun-2014 18:34:07 Europe/Berlin] PHP Warning: array_merge() [http://php.net/function.array-merge'>function.array-merge]: Argument #1 is not an array in C:\xampp\htdocs\website\View\Helper\MenuHelper.php on line 74
[13-Jun-2014 18:34:07 Europe/Berlin] PHP Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\website\View\Helper\MenuHelper.php on line 85
My other page which was in the same htdocs folder is running fine (it isn't using cakephp). Any ideas what could have happened? Any idea how to find out where this is called since it seems to be a cakephp-Helper?
EDIT:
Seems I missed 2 lines in the php_error.log:
PHP Notice: Undefined variable: login in C:\xampp\htdocs\website\View\Layouts\default.ctp on line 2
PHP Notice: Undefined variable: menu in C:\xampp\htdocs\website\View\Layouts\default.ctp on line 82
some see me the same, that's what I did, just copy the folder app, after creates a new project and copy the app folder and replaces the app folder. and shuld be found. I look the reason of the problem and just read about the cookies and cache. And the option that a give you is more easy.
The problem was that I was using a new version of xampp but did not update cakephp to the newest version. After doing so everything worked fine.

Categories