Static PHP array throws Error 500 on every call - php

I have got a little problem. My application runs into a Error 500 each time this line of code is executed in PHP 7.2 (PHP 5.6 was fine)
function selfDbDM($query,$type=0)
{
global $db;
static $db_exe = array();
$error = 0;
if($type==0)
{
$db_exe[] = $query;
}
else
{
//Do Something
}
}
The calling script simply just calls
selfDbDM('SQL QUERY ...');
selfDbDM('SQL QUERY 2 ...');
etc.
Then it calls
selfDbDM('',1);
to submit every change to DB.
I am doing it that way, so that I can use mysqli_autocommit in a simple way.
Now the thing is, I have switched the server for better performance and now the code is not working anymore.
EDIT:
Errorlog
[Tue Oct 15 22:55:51.371463 2019] [fcgid:warn] [pid 11859:tid 140389409335040] [client 37.201.185.7:8833] mod_fcgid: stderr: Stack trace:, referer: https://xyz/index.php?page=contract_new&step=2
[Tue Oct 15 22:55:51.371468 2019] [fcgid:warn] [pid 11859:tid 140389409335040] [client 37.201.185.7:8833] mod_fcgid: stderr: #0 /var/www/vhosts/xyz/public/system/page/contract_new.php(171): selfDbDM('INSERT INTO `ko...'), referer: https://xyz/index.php?page=contract_new&step=2
[Tue Oct 15 22:55:51.371472 2019] [fcgid:warn] [pid 11859:tid 140389409335040] [client 37.201.185.7:8833] mod_fcgid: stderr: #1 /var/www/vhosts/xyz/public/system/page/contract_new.php(340): contract_new_save_step2(), referer: https://xyz/index.php?page=contract_new&step=2
[Tue Oct 15 22:55:51.371477 2019] [fcgid:warn] [pid 11859:tid 140389409335040] [client 37.201.185.7:8833] mod_fcgid: stderr: #2 /var/www/vhosts/xyz/include/core.function.php(300): init_contract_new(), referer: https://xyz/index.php?page=contract_new&step=2
[Tue Oct 15 22:55:51.371481 2019] [fcgid:warn] [pid 11859:tid 140389409335040] [client 37.201.185.7:8833] mod_fcgid: stderr: #3 /var/www/vhosts/xyz/public/system/index.php(58): include_page('contract_new', '/var/www/vhosts...', '/var/www/vhosts...'), referer: https://xyz/index.php?page=contract_new&step=2
[Tue Oct 15 22:55:51.371485 2019] [fcgid:warn] [pid 11859:tid 140389409335040] [client 37.201.185.7:8833] mod_fcgid: stderr: #4 {main}, referer: https://xyz/index.php?page=contract_new&step=2
[Tue Oct 15 22:55:51.372000 2019] [fcgid:warn] [pid 11859:tid 140389409335040] [client 37.201.185.7:8833] mod_fcgid: stderr: thrown in /var/www/vhosts/xyz/include/functions_mysql.php on line 132, referer: https://xyz/index.php?page=contract_new&step=2
EDIT 2:
Fatal error: Uncaught Error: [] operator not supported for strings in /var/www/vhosts/cash-keeper.eu/dev2.cash-keeper.eu/include/functions_mysql.php:132

Found the issu...
PHP told me everytime that line 132 was the problem.
That was this line:
$db_exe[] = $query;
But a couple of lines later, after one successfull db commit, the array gets cleared like that
$db_exe = '';
Well PHP 7.2 doesn't support that type of "its a string, but we need an array, then its an array" anymore.
So the real problem was, that in the first db commit was doing alright because it was an array. After that one it got cleared to a string, in the secound round to commit something to the db, that could not work anymore.
The fix was just to change the line where the array was cleared to this:
$db_exe = array();
Well thanks to all.

Related

PHP Fatal error: require(): Failed opening required 'template/header.phtml' (include_path='.:/usr/share/php')

I have created a website and just uploaded it on a virtual host, but when I try accessing it I get the "This page isn’t working (HTTP ERROR 500)" and I got this from the error log file, I understand it is something to do with the file paths but I don't know how to fix it. does anyone know how to fix it?
[Sun Dec 20 00:18:28.000823 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP Warning: require(/home/ae504/public_html/AuctionSystem/View/Template/header.phtml): failed to open stream: No such file or directory in /home/aee504/public_html/AuctionSystem/View/index.phtml on line 1
[Sun Dec 20 00:18:28.000849 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP Stack trace:
[Sun Dec 20 00:18:28.000853 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP 1. {main}() /home/aee504/public_html/AuctionSystem/index.php:0
[Sun Dec 20 00:18:28.000856 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP 2. require_once() /home/aee504/public_html/AuctionSystem/index.php:5
[Sun Dec 20 00:18:28.000859 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP Fatal error: require(): Failed opening required '/home/ae504/public_html/AuctionSystem/View/Template/header.phtml' (include_path='.:/usr/share/php') in /home/aee504/public_html/AuctionSystem/View/index.phtml on line 1
[Sun Dec 20 00:18:28.000862 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP Stack trace:
[Sun Dec 20 00:18:28.000865 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP 1. {main}() /home/aee504/public_html/AuctionSystem/index.php:0
[Sun Dec 20 00:18:28.000868 2020] [fcgid:warn] [pid 2449] [client 89.168.52.229:52594] mod_fcgid: stderr: PHP 2. require_once() /home/aee504/public_html/AuctionSystem/index.php:5
/home/ae504/public_html/AuctionSystem/View/Template/header.phtml
The file doesn't exist or is not readable. Simple *nix error
Either your templating engine is not producing it, or it is being produced but not readable. Given your error report, there is no way of telling. Suggest you go look at whatever framework you are using.

Evernote Api : How can i get a list of my account notes that is linked with the developer account

I've tested all of the php examples that came with the API and none gives me results.
The Api was installed with composer.
i have some errors resulted when running the script ( ips,locations,keys were changed here )
[Sat Apr 20 02:20:51.324822 2019] [fcgid:warn] [pid 25930] [client *ip*] mod_fcgid: stderr: PHP Fatal error: Uncaught EDAM\\Error\\EDAMUserException in /server/public_html/vendor/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php:2603
[Sat Apr 20 02:20:51.324885 2019] [fcgid:warn] [pid 25930] [client *ip*] mod_fcgid: stderr: Stack trace:
[Sat Apr 20 02:20:51.324899 2019] [fcgid:warn] [pid 25930] [client *ip*] mod_fcgid: stderr: #0 /server/public_html/vendor/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php(543): EDAM\\UserStore\\UserStore_getUser_result->read(Object(Thrift\\Protocol\\TBinaryProtocol))
[Sat Apr 20 02:20:51.324913 2019] [fcgid:warn] [pid 25930] [client *ip*] mod_fcgid: stderr: #1 /server/public_html/vendor/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php(504): EDAM\\UserStore\\UserStoreClient->recv_getUser()
[Sat Apr 20 02:20:51.324925 2019] [fcgid:warn] [pid 25930] [client *ip*] mod_fcgid: stderr: #2 [internal function]: EDAM\\UserStore\\UserStoreClient->getUser('oceanindien-ful...')
[Sat Apr 20 02:20:51.324936 2019] [fcgid:warn] [pid 25930] [client *ip*] mod_fcgid: stderr: #3 /server/public_html/vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Store/Store.php(50): call_user_func_array(Array, Array)
[Sat Apr 20 02:20:51.324973 2019] [fcgid:warn] [pid 25930] [client *ip*] mod_fcgid: stderr: #4 /server/public_html/test.php(207): Evernote\\Store\\Store->__call('getUser', Array)
[Sat Apr 20 02:20:51.324984 2019] [fcgid:warn] [pid 25930] [client *ip*] mod_fcgid: stderr: #5 {main}
[Sat Apr 20 02:20:51.324993 2019] [fcgid:warn] [pid 25930] [client *ip*] mod_fcgid: stderr: thrown in /server/public_html/vendor/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php on line 2603
$token = 'my-real-token-here';
$sandbox = true;
$china = false;
$client = new \Evernote\Client($token, $sandbox, null, null, $china);
$search = new \Evernote\Model\Search('comores');
$notebook = null;
$scope = \Evernote\Client::SEARCH_SCOPE_BUSINESS;
$order = \Evernote\Client::SORT_ORDER_REVERSE | \Evernote\Client::SORT_ORDER_RECENTLY_CREATED;
$maxResult = 5;
$results = $client->findNotesWithSearch($search, $notebook, $scope, $order, $maxResult);
var_dump($results);
foreach ($results as $result) {
$noteGuid = $result->guid;
$noteType = $result->type;
$noteTitle = $result->title;
$noteCreated = $result->created;
$noteUpdated = $result->updated;
}
I've checked the linked account that has notes with those tags or keys but the api gives me no results returned.
How can i get the list of my TAGS from the linked account ?
How can i get a list of my notes and/or notebooks from my account ?
The sandbox key is full access not basic.
I've searched for examples that i tried on the server, but the return was or ERROR 500 or empty page,
I've echo/printed the results but no results returned !
What i do wrong, or what do i need to do so the api work ?

error reading data from FastCGI server

I get the following error:
[Fri Dec 22 19:45:04.824183 2017] [fcgid:warn] [pid 11484:tid 140643225478912] (104)Connection reset by peer: [client xx.xx.xx.xx] mod_fcgid: error reading data from FastCGI server, referer: http://8-bit.nl/ag-admin/import.php?action=node
[Fri Dec 22 19:45:04.824289 2017] [core:error] [pid 11484:tid 140643225478912] [client xx.xx.xx.xx] End of script output before headers: getSpecificNode.php, referer: http://8-bit.nl/ag-admin/import.php?action=node
It's a PHP-script which reads XML files and post this into the database.
I found online that it has something to do with FcgidBusyTimeout. How can I change this value in .htaccess? I'm on shared hosting.

Apache2 won't run a Script, PHP-CLI do

I've wrote a script which reads a log-file and write it into an Database. Because of many different line-types it would take about 30 minits executiontime.
Log-Files got:
~20 MB filesize
~200.000 lines
If I include it to my website, the script would run only with small log-files(~2MB tested), it won't run till end if i'm using normal-log-files. I included the script like this:
<?php
include "logLauncher/main.php";
?>
The strange thing is if i using a syscall it would run.
<?php
system("php5 logLauncher/main.php");
?>
Three last entrys in file: /var/log/apache2/error.log
[Wed Aug 26 11:11:22.210994 2015] [:error] [pid 18893] [client 192.168.0.100:54746] PHP 1. {main}() /var/www/cowrean_logs/alpha/main.php:0, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=2&left=1&right=1&event=5&trigger=18200&focus=2&filter1=&encounter=11982&&start=2015-05-27%2019:59:07&end=2015-05-27%2020:00:48
[Wed Aug 26 11:11:22.211004 2015] [:error] [pid 18893] [client 192.168.0.100:54746] PHP 2. include() /var/www/cowrean_logs/alpha/main.php:121, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=2&left=1&right=1&event=5&trigger=18200&focus=2&filter1=&encounter=11982&&start=2015-05-27%2019:59:07&end=2015-05-27%2020:00:48
[Wed Aug 26 11:11:22.211014 2015] [:error] [pid 18893] [client 192.168.0.100:54746] PHP 3. include() /var/www/cowrean_logs/alpha/mod_focus.php:192, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=2&left=1&right=1&event=5&trigger=18200&focus=2&filter1=&encounter=11982&&start=2015-05-27%2019:59:07&end=2015-05-27%2020:00:48
[Wed Aug 26 11:11:28.131411 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP Notice: A session had already been started - ignoring session_start() in /var/www/cowrean_logs/alpha/main.php on line 47, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=2&left=1&right=1&event=5&trigger=18200&focus=2&filter1=&encounter=11982&start=2015-05-27%2019:59:07&end=2015-05-27%2020:00:48
[Wed Aug 26 11:11:28.131462 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP Stack trace:, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=2&left=1&right=1&event=5&trigger=18200&focus=2&filter1=&encounter=11982&start=2015-05-27%2019:59:07&end=2015-05-27%2020:00:48
[Wed Aug 26 11:11:28.131481 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP 1. {main}() /var/www/cowrean_logs/alpha/main.php:0, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=2&left=1&right=1&event=5&trigger=18200&focus=2&filter1=&encounter=11982&start=2015-05-27%2019:59:07&end=2015-05-27%2020:00:48
[Wed Aug 26 11:11:28.131494 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP 2. session_start() /var/www/cowrean_logs/alpha/main.php:47, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=2&left=1&right=1&event=5&trigger=18200&focus=2&filter1=&encounter=11982&start=2015-05-27%2019:59:07&end=2015-05-27%2020:00:48
[Wed Aug 26 11:11:29.080694 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP Notice: A session had already been started - ignoring session_start() in /var/www/cowrean_logs/alpha/main.php on line 47, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=1&left=4&right=0
[Wed Aug 26 11:11:29.080728 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP Stack trace:, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=1&left=4&right=0
[Wed Aug 26 11:11:29.080741 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP 1. {main}() /var/www/cowrean_logs/alpha/main.php:0, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=1&left=4&right=0
[Wed Aug 26 11:11:29.080751 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP 2. session_start() /var/www/cowrean_logs/alpha/main.php:47, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=1&left=4&right=0
[Wed Aug 26 11:11:29.081747 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP Notice: Undefined property: mysqli::$close in /var/www/cowrean_logs/alpha/mod_execute_log.php on line 131, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=1&left=4&right=0
[Wed Aug 26 11:11:29.081769 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP Stack trace:, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=1&left=4&right=0
[Wed Aug 26 11:11:29.081790 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP 1. {main}() /var/www/cowrean_logs/alpha/main.php:0, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=1&left=4&right=0
[Wed Aug 26 11:11:29.081801 2015] [:error] [pid 18894] [client 192.168.0.100:54747] PHP 2. include() /var/www/cowrean_logs/alpha/main.php:118, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?top=1&left=4&right=0
[Wed Aug 26 11:11:35.819211 2015] [:error] [pid 21277] [client 192.168.0.100:54748] PHP Notice: A session had already been started - ignoring session_start() in /var/www/cowrean_logs/alpha/main.php on line 47, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?left=7&top=1&right=0
[Wed Aug 26 11:11:35.819247 2015] [:error] [pid 21277] [client 192.168.0.100:54748] PHP Stack trace:, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?left=7&top=1&right=0
[Wed Aug 26 11:11:35.819267 2015] [:error] [pid 21277] [client 192.168.0.100:54748] PHP 1. {main}() /var/www/cowrean_logs/alpha/main.php:0, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?left=7&top=1&right=0
[Wed Aug 26 11:11:35.819279 2015] [:error] [pid 21277] [client 192.168.0.100:54748] PHP 2. session_start() /var/www/cowrean_logs/alpha/main.php:47, referer: http://192.168.0.10/cowrean_logs/alpha/main.php?left=7&top=1&right=0
I would not post whole config-files because "/etc/php5/apache2/php.ini" and "/etc/php5/cli/php.ini" got more than 600 lines!
I think these lines could be interested, but they are in both files identical -.-
post_max_size = 20M
max_execution_time = 30
memory_limit = -1
Got anyone have a solution for me to kick out the syscall from my code? And include the log-reader script directly into my page? Syscalls doesn't look fine!
Ubuntu 14.4
PHP5
Apache2
PHP-CLI
In the script in question add this at the top of the code
<?php
ini_set('max_execution_time', -1 );
This will tell PHP not to timeout this script.
It has its dangers, for example if you manage to code and infinite loop then the script will run till you kill either apache or PHP, depending on your configuration.
It is best not to change this in the php.ini as that will effect every php script.

cakephp and imagick - raw files won't upload

When I upload a JPEG everything works just fine. However, when upload a RAW it does work. I have the php.ini upload limits set to 25M. I was able to upload a 7MB JPEG file but not a 7MB RAW file. Below is the error I am recieving:
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: PHP Fatal error: Uncaught exception 'ImagickException' with message 'Can not process empty wand' in /home/photobound/public_html/plugins/photo_bank/models/photo_bank_image.php:264, referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: Stack trace:, referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: #0 /home/photobound/public_html/plugins/photo_bank/models/photo_bank_image.php(264): Imagick->getimagewidth(), referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: #1 /home/photobound/public_html/plugins/photo_bank/models/photo_bank_image.php(124): PhotoBankImage->computeImageFieldsForSave(), referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: #2 /usr/share/php/cake/cakephp/cake/libs/model/model.php(1282): PhotoBankImage->beforeSave(Array), referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: #3 /home/photobound/public_html/plugins/photo_bank/controllers/photo_bank_images_controller.php(131): Model->save(Array), referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: #4 [internal function]: PhotoBankImagesController->upload('-1'), referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: #5 /usr/share/php/cake/cakephp/cake/dispatcher.php(204): call_user_func_array(Array, Array), referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: #6 /usr/share/php/cake/cakephp/cake/dispatcher.php(171): Dispatcher->_invoke(Object(PhotoBankImagesController), Array), referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: #7 /home/photobound/public_html/webroot/index.php(84): Dispatcher->dispatch(), referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: #8 {main}, referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
[Wed Aug 17 17:23:55 2011] [warn] [client 192.168.1.6] mod_fcgid: stderr: thrown in /home/photobound/public_html/plugins/photo_bank/models/photo_bank_image.php on line 264, referer: http://photobound.local/photo_bank/js/plupload/plupload.flash.swf
Here is the code on line 264:
$this->data['PhotoBankImage']['width'] = $this->image->getImageWidth();
Here are my php.ini settings that I thought were relevent:
post_max_size = 25M
post_max_size = 25M
memory_limit = 512M
max_execution_time = 120
max_input_time = 120
I'd appreciate any help, let me know if you need anything else from me in order understand the problem.
RAW files are not standard images. Standard graphics libraries are not going to be able to work with them. The format varies depending on camera make/model, etc.

Categories