Jump to content

public static function PilotAircraftFlownCounts($pilotid)


Ricky310

Recommended Posts

How do I fix this function?  StatsData::<?php echo PilotSircraftflownCounts($pilot->pilotid); ?>     When I type this in, The output is the word "array" I am running phpvms 5.5.2 and TFDIdesign is the host. I do not know nothing about php, java script, I know basic HTML.

 

Can anyone show me the script I need to add to this function to make it work? Thanks.

Link to comment
Share on other sites

Looks like you are trying to echo an array, you may need to do a loop in that array to get the results or implode it ... Solution depends on the array structure and contents, also your expected result.

 

https://www.php.net/manual/en/language.types.array.php

 

https://www.php.net/manual/en/function.implode.php

 

https://www.php.net/manual/en/control-structures.foreach.php

Link to comment
Share on other sites

  • Administrators

Need to see the entire error message.

Is this in the default phpVMS 5.5.2 files or an addon module?

If an addon module, which one?

What is the file name and line number?

 

What PHP version?

What MySql or MariaDB version?

Link to comment
Share on other sites

DesposableHero I do not know anything about PHP or ARRAY's. I would need to have someone write the script  for me.

 

ProAvia no error message, just the word "Array". This a default function from the file name core/common/StatsData.class.php. Refer you to line 456, (public static function PilotAircraftFlownCounts($pilotid) )

 

PHP version is 5.3.29

Mysql version is 5.7.34-cll-lve

Link to comment
Share on other sites

I do not know if error reporting if turned on. And no there is nothing in the error_log file.  From what you are telling me, this function needs to be rewritten with a new script or maybe it will never work??? I will work on getting you an error message. 

Link to comment
Share on other sites

  • Administrators

It could be something very simple or something very complex. Without the error log, no telling what the issue is.

 

You say you are "typing it in". Exactly what are you typing in? What is the expected output?

 

The line you reference is actually line 453 (not 456) in the default StatsData.class.php file. Check to see if it works with the default file.

 

And the pie chart that is supposed to display may no longer work because Flash Chart (or whatever it was called) is no longer supposed/available in most browsers. Search the forums for Morris Chart or Google Chart to see if there is a possible alternate to use.

 

Link to comment
Share on other sites

I understand. I add this statement to a column in a table-> StatsData::<?php echo PilotSircraftflownCounts($pilot->pilotid); ?>

 

The output that I am hoping for is a table with two columns. The Name of the aircraft flown and the hours flown in each aircraft by each pilot. I am adding this to the profile_main.php.

 

I have also tried -> StatsData::<?php echo PilotSircraftflownCounts($userinfo->pilotid); ?>  and either of them work. The output is the same. The word "array".

 

I done the default StatsData.class.php file. Same output.

 

I do have a pie chart working. There is one I found with Google chart and it shows the aircraft flown, but no hours.

 

I wish I could find a script that I could add to the profile_main.php that would give me the aircraft flown and hours for each pilot in my VA. No luck and would most likely have to pay someone, Paying someone is not a option, I will do without. I do think the script would go viral with all the VA's that use phpvms. IMO.

 

 

Link to comment
Share on other sites

  • Administrators

There are possibly some payware alternatives - or you could try to write your own.

 

One issue I see is you say:

"... PilotSircraftflownCounts ...."

when it should be

... PilotAircraftflownCounts ...

The 'S' should be an 'A'

Link to comment
Share on other sites

NO, When I posted this, I made a typing error. 

 

This is the script I am refering to:

 

 /**
     * StatsData::PilotAircraftFlownCounts()
     *
     * @param mixed $pilotid
     * @return
     */
    public static function PilotAircraftFlownCounts($pilotid) {

        $key = 'ac_flown_counts_' . $pilotid;
        
        
        $counts = CodonCache::read($key);
        if ($counts === false) {
            //Select aircraft types
            $sql = 'SELECT a.name AS aircraft, COUNT(p.aircraft) AS count, SUM(p.flighttime) AS hours
                    FROM ' . TABLE_PREFIX . 'pireps p, ' . TABLE_PREFIX . 'aircraft a
                    WHERE p.aircraft = a.id AND p.pilotid=' . intval($pilotid) . '
                    GROUP BY a.name';

            $counts = DB::get_results($sql);
            CodonCache::write($key, $counts, 'medium');
        }

        return $counts;
    }

Edited by Ricky310
Link to comment
Share on other sites

  • 3 weeks later...

After further investigation , I suspect there is a error in the CodonCache.php file. That will not allow this function to work properly. It is these lines of script that I am refering to:  $counts = CodonCache::read($key);   and    CodonCache::write($key, $counts,  'medium'); . This is way above my skill level to fix and way too expensive to hire someone. I got a quote from a web designer, $500 to $700 USD. This is highway robbery.

 

I will do without this function and keep my aircraft hours on a spread sheet. 

 

I have yet to find a Virtual Airline that uses Pilots Aircraft Hours stat, or this function.

 

Cheers!

Link to comment
Share on other sites

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...