Jump to content

count(): Parameter must be an array or an object that implements Countable [SOLVED]


Recommended Posts

Posted

Another day, another error 😀

 

Wondering if anyone could assist. I was looking to approve a PIREP in the admin panel and got 2 errors:

 

-Warning: count(): Parameter must be an array or an object that implements Countable in /home/tstamer/public_html/crew/admin/modules/PIREPAdmin/PIREPAdmin.php on line 120
-Warning: Invalid argument supplied for foreach() in /home/tstamer/public_html/crew/admin/modules/PIREPAdmin/PIREPAdmin.php on line 122
0 of 0 were approved (0 has errors)

 

Ive looked around the internet for solutions to fix and while there are several suggestion on how to fix, i swear its like reading a different language! I can't wrap my head around it.

phpVMS 5.5.2 - PHP 5.6

Here is that section on the PIREPAdmin.php from admin/modules/:
 

public function approveall() {
        $this->checkPermission(MODERATE_PIREPS);
        
        echo '<h3>Approve All</h3>';

        $allpireps = PIREPData::findPIREPS(array('p.accepted' => PIREP_PENDING));
        
        $total = count($allpireps);
        $count = 0;
        foreach ($allpireps as $pirep_details) {
            
            if ($pirep_details->aircraft == '') {
                continue;
            }

            # Update pilot stats
            SchedulesData::IncrementFlownCount($pirep_details->code, $pirep_details->flightnum);
            PIREPData::ChangePIREPStatus($pirep_details->pirepid, PIREP_ACCEPTED); // 1 is accepted
            #PilotData::UpdatePilotStats($pirep_details->pilotid);

            #RanksData::CalculateUpdatePilotRank($pirep_details->pilotid);
            RanksData::CalculatePilotRanks();
            #PilotData::GenerateSignature($pirep_details->pilotid);
            #StatsData::UpdateTotalHours();
            CodonEvent::Dispatch('pirep_accepted', 'PIREPAdmin', $pirep_details);

            $count++;
        }

        $skipped = $total - $count;
        echo "$count of $total were approved ({$skipped} has errors)";
    }

 

Thanks

  • Moderators
Posted

phpVMS has several count functions. As @ProAvia said, you are probably using PHP 7.2. I would open my core/local.config.php and find "ERROR_LEVEL" and set its statement to something like that:

Config::Set('ERROR_LEVEL', E_ALL ^ E_NOTICE);

That should hide all the warnings.

Posted (edited)
3 hours ago, ProAvia said:

The first thing I would do is to verify that the directory phpVMS is in is using PHP 5.6 and not some version of PHP7. You shouldn't get that error in PHP 5.6 .

 

Create a phpinfo.php file to check the PHP info of the phpVMS directory.

https://mediatemple.net/community/products/dv/204643880/how-can-i-create-a-phpinfo.php-page

 

@ProAvia

I have been getting all kinds of PHP 7 errors. My php version is set to 5.6 and running phpvms 5.5.2. I don't know why I am running 7.2.29 per phpinfo or how to change it to what it should be.
http://www.test.americanva.org/phpinfo.php

@servetas

I sent you a ticket for the academy that has an error in the admin panel. Could the be the reason for it?

Edited by djtiger76
  • Administrators
Posted

I am not a big fan of just hiding the errors. The error you are seeing is because you are running php 7.2.29 and not php 5.6

 

I would suggest asking your hosting company to help you set the phpVMS directory to use php 5.6 - if they have that php version available. Or.... contact me via PM and provide your cPanel login details and I will take a look.

Posted

mp hosting provider TFDi changed their host. So its been causing me a headache for the past couple days. The ability to change php version is no longer available, and im sure they changed my version to 7.2. I put in a ticket with them.

  • Administrators
Posted

Actually there is a way to change the php version on the TFDI servers - as one of my fellow developers uses them and is able to do it. It's in a new section. Let me see if he can point you in the general direction.

Posted (edited)
42 minutes ago, djtiger76 said:

mp hosting provider TFDi changed their host. So its been causing me a headache for the past couple days. The ability to change php version is no longer available, and im sure they changed my version to 7.2. I put in a ticket with them.

If you log in to the tfdi cpanel scroll the PHP section you are looking for the icon that is labelled multiphp manager. From there select the domain or subdomain with a tick in the check box then upper right side you will see a drop down to select the version you wish to have as the active.

 

Select and apply and your good to go 

Edited by VectoringDesigns
  • Like 1
  • 1 year later...
Posted (edited)

Hello Gentlemen,

after racking your brain, I found something that can help you in the PHP7 version for this error, follow:

 

In my case the error was in this line: if(count($pireps) > 0)

 

So I used: if(is_array($seu-array) && count($seu-array) > 0)

 

if (is_array ($pireps) && count ($pireps)> 0)

 

Hope this helps! hugs!

Edited by fnbv

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...