stephanepa38 Posted October 16, 2009 Report Posted October 16, 2009 Hello I would like to put on my ftp servor a table which presents the pilot list with only the date of the last flight. This page will be public, so all the people will see it without registering. I tried to do this php page with this code I found in this forum : <?php $report = PIREPData::GetLastReports($pilot->pilotid, 1); echo date('d.M.Y', strtotime($report->submitdate)); ?> But when I use this code, nothing happens. How can I do to do this page with only the pilot list and the date of the last flight ? Thanks Stéphane Quote
Administrators simpilot Posted October 16, 2009 Administrators Report Posted October 16, 2009 Your code works fine on my pilots table... What version are you running? Quote
Administrators simpilot Posted October 16, 2009 Administrators Report Posted October 16, 2009 If you want to do a little more with it since if a pilot has not flown any flights the system returns a date of Dec 31 1969 you could use the code below to show "No Flights" instead of the old date.. <?php $report = PIREPData::GetLastReports($pilot->pilotid, 1); $check = date('Y', strtotime($report->submitdate)); if ($check=="1969") { echo 'no flights'; } else { $last = date('M.d.Y', strtotime($report->submitdate)); echo $last; } ?> Quote
Administrators Nabeel Posted October 17, 2009 Administrators Report Posted October 17, 2009 The last PIREP date is stored in the pilot's table, in the 'lastpirep' field, as a datetime, so you could do: <?php $pilots = PilotData::GetAllPilots(); foreach($pilots as $pilot) { echo "{$pilot->firstname} {$pilot->lastname} - {$pilot->lastpirep}<br />"; } When using double quotes in a string, it's good practice to encapsulate variables in { } You can check if it's null (this is the default value, it's only updated when there's a PIREP): if($pilot->lastpirep == '0000-00-00 00:00:00') { echo 'No PIREP'; } else { // What David suggested: echo date('m-d-Y', strtotime($pirep->lastpirep)); } This will be the most reliable way. Also, not sure if you knew, if this is outside of phpVMS, you have to: <?php include '/path/to/core/codon.config.php'; Then anything with the API should work. Quote
stephanepa38 Posted October 17, 2009 Author Report Posted October 17, 2009 Hello Thank you for your ansers. I put this code on an lastflight.php page in my ftp servor, but outside of the phpvms folder : <?php include '/path/to/core/codon.config.php'; $pilots = PilotData::GetAllPilots(); foreach($pilots as $pilot) { echo "{$pilot->firstname} {$pilot->lastname} - {$pilot->lastpirep}<br />"; } if($pilot->lastpirep == '0000-00-00 00:00:00') { echo 'No PIREP'; } else { // What David suggested: echo date('m-d-Y', strtotime($pirep->lastpirep)); } ?> But I still have a blank page (without any information) when I want to see this page with only this code. Did I make an error ? Thanks Stéphane Quote
Administrators simpilot Posted October 17, 2009 Administrators Report Posted October 17, 2009 include '/path/to/core/codon.config.php'; You have to change this to the path to the file on your server. Probably something like.. include '/myairlinefolder/core/codon.config.php'; Quote
stephanepa38 Posted October 17, 2009 Author Report Posted October 17, 2009 I've done it, but I still have the blank page. Stéphane Quote
Administrators Nabeel Posted October 18, 2009 Administrators Report Posted October 18, 2009 You have the right path? Before and after that include line, put: error_reporting(E_ALL); ini_set('display_errors', 'on'); Hopefully that will give some sort of clue as to the error Quote
stephanepa38 Posted October 19, 2009 Author Report Posted October 19, 2009 Now, I have this error : Warning: include() [function.include]: Failed opening '/phpvms/core/codon.config.php' for inclusion (include_path='.') in /home/vol4/byethost31.com/b31_3600827/htdocs/lastflight.php on line 5 Fatal error: Class 'PilotData' not found in /home/vol4/byethost31.com/b31_3600827/htdocs/lastflight.php on line 10 Stéphane Quote
Administrators Nabeel Posted October 19, 2009 Administrators Report Posted October 19, 2009 Your include path is wrong. Try without that leading / in front of it Quote
stephanepa38 Posted October 20, 2009 Author Report Posted October 20, 2009 Now I have two others errors which are listed, but I have the last flight list. Thanks for all. Stéphane Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.