Cope with mysql errors even with php ver. < 8; check if $link is false before trying to close mysql connection in function mexit
This commit is contained in:
parent
e46a82d923
commit
b46469bfbb
1 changed files with 3 additions and 3 deletions
|
@ -832,8 +832,8 @@ function myq(&$link,$query,$line) {
|
|||
catch (Exception $error) {
|
||||
mexit('query «'.$query.'» (line '.$line.') failed: '.$error->getMessage().N,3);
|
||||
}
|
||||
// for older php versions, which seem to not catch mysql exceptions
|
||||
if ($res===false) mexit('query «'.$query.'» (line '.$line.') failed: '.mysqli_errno($link).': '.mysqli_error($link).N,3);
|
||||
// for php versions < 8, which seem to not catch mysql exceptions
|
||||
if ($res===false) mexit('query «'.$query.'» (line '.$line.') failed: '.mysqli_errno($link).': '.mysqli_error($link).'.'.N,3);
|
||||
return($res);
|
||||
}
|
||||
|
||||
|
@ -854,7 +854,7 @@ function eecho($lev,$msg) {
|
|||
|
||||
function mexit($msg,$code) {
|
||||
global $link, $jsonf, $logf, $lockfp;
|
||||
if (isset($link)) mysqli_close($link);
|
||||
if (isset($link) && $link!==false) mysqli_close($link);
|
||||
if (isset($jsonf) && $jsonf!==false) fclose($jsonf);
|
||||
if (isset($logf) && $logf!==false) fclose($logf);
|
||||
if (isset($lockfp) && is_file($lockfp)) unlink($lockfp);
|
||||
|
|
Loading…
Reference in a new issue