ProjeQtOr free project management software - Error in headerFunctions.php : Parameter must be an array - ProjeQtOr
 

Error in headerFunctions.php : Parameter must be an array

More
19 Mar 2020 15:13 #1 by antoine1003
Hi,
I am trying to create a custom report but I got a error really strange.
Error :
2020-03-19 14:58:18.888 ***** ERROR ***** [V8.3.2] on file 'C:\wamp64\www\ipmp_new\report\headerFunctions.php' at line (54)
2020-03-19 14:58:18.893 ***** ERROR ***** [V8.3.2] cause = count(): Parameter must be an array or an object that implements Countable
Here is the code which produce the bug :
$queryWhere = ($queryWhere == '') ? ' 1=1' : $queryWhere;
$query = 'select ' . $querySelect
    . ' from ' . $queryFrom
    . ' where ' . $queryWhere;
$result = Sql::query($query);
if (checkNoData($result)) exit; // The error occurs in that function
The variable $query contains this query :
select `id`, DATE_FORMAT(`externalValidation`, '%Y%m%d') `delivered`, DATE_FORMAT(`externalValidationScheduled`, '%Y%m%d') `planned`, DATE_FORMAT(`externalValidation`, '%Y-%m') `interval` from `document` where `idProject` IN (0, 100) AND `externalValidationScheduled` IS NOT NULL AND `externalValidation` BETWEEN '2020-03-01' AND '2021-02-28' AND `idDocumentType` = '63'

When I run this query in PHP my admin it return 0 row but no error.

The begin of function checkNoData :
function checkNoData($result, $month=null) {
  global $outMode;
  if (count($result)==0) { // Error is thrown here

The $result parameter :


I don't understand why the Sql::query doesn't return proper value :'(

Please Log in or Create an account to join the conversation.

More
19 Mar 2020 19:44 #2 by babynus
checkNoData() expects an array as parameter.
You send a resource to a query.

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

Moderators: babynusprotion
Time to create page: 0.023 seconds