-1

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

1 Answers1

0

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.