Jump to content

Recommended Posts

Posted

I am getting this error for the "Latest Flights" gcmap:

Warning: Invalid argument supplied for foreach() in /home/luvswavi/public_html/lib/skins/airlines/frontpage_main.tpl on line 57

Line 57 is: foreach($flights as $flight)

Also, the Map is on the left side of the webpage, how can I center it? I googled that several times and couldn't find a way to do it.

Posted

I am getting this error for the "Latest Flights" gcmap:

Warning: Invalid argument supplied for foreach() in /home/luvswavi/public_html/lib/skins/airlines/frontpage_main.tpl on line 57

Line 57 is: foreach($flights as $flight)

Also, the Map is on the left side of the webpage, how can I center it? I googled that several times and couldn't find a way to do it.

Above:

foreach($flights as $flight)

Add:

$flights = ACARSData::GetACARSData();

And use css to center:

<div id="gcmap">
<!--- Map Code --->
</div>

CSS CODE:

#gcmap{

position:absolute;
alignment-adjust:central;
/*here you should go adjusting until your map is centered on the page*/
margin-left:50%;
}

Posted

Okay the error on line 57 I placed $flights = ACARSData::GetACARSData( ); below, above, in front of and behind foreach($flights as $flight)and I am still getting the same error. Also I could not get the CSS code to work for centering the map.

Can you show me how these are suppose to look? Here is the code I am sing for the map:

<img src="http://www.gcmap.com/map?P=<?php echo $string ?>&MS=bm&MR=240&MX=650x360&PM=pemr:diamond7:red%2b%22%25I%22:red&PC=%230000ff" /><br />

Maps generated by the <a href="http://www.gcmap.com/">Great Circle Mapper</a> - copyright © <a href="http://www.kls2.com/~karl/">Karl L. Swartz</a>

<!--Start Table-->

<?php

$count = 5;

$pireps = PIREPData::getRecentReportsByCount($count);

?>

<table width="725 px" border="1" bordercolor="#FFFFFF">

<thead>

<tr align="center" valign="middle" bgcolor="#7D95AF">

<th>Flight #</th>

<th>Departure</th>

<th>Arrival</th>

<th>Duration</th>

<th>Pilot</th>

<th>Landing Rate</th>

<th>Aircraft</th>

</tr>

</thead>

<tbody>

<?php

if(count($pireps) > 0)

{

foreach ($pireps as $pirep)

{

$pilotinfo = PilotData::getPilotData($pirep->pilotid);

$pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);

echo "<tr>";

echo "<td align=center> $pirep->code $pirep->flightnum </td>";

echo "<td align=center> $pirep->depicao </td>";

echo "<td align=center> $pirep->arricao </td>";

echo "<td align=center> $pirep->flighttime </td>";

echo "<td align=center> $pilotid $pilotinfo->firstname $pilotinfo->lastname </td>";

echo "<td align=center> $pirep->landingrate </td>";

echo "<td align=center> $pirep->aircraft </td>";

echo "</tr>";

}

}

else

{

echo "<tr><td>There are no recent flights!</td></tr>";

}

?>

</table>

</td>

Posted

Okay the error on line 57 I placed $flights =ACARSData::GetACARSData( ); below, above, in front of and behind foreach($flights as $flight)and I am still getting the same error. Also I could not get the CSS code to work for centering the map.

Can you show me how these are suppose to look? Here is the code I am sing for the map:

<img src="http://www.gcmap.com/map?P=<?php echo $string ?>&MS=bm&MR=240&MX=650x360&PM=pemr:diamond7:red%2b%22%25I%22:red&PC=%230000ff" /><br />

Maps generated by the <a href="http://www.gcmap.com/">Great Circle Mapper</a> - copyright © <a href="http://www.kls2.com/...om/~karl/">Karl L. Swartz</a>

<!--Start Table-->

<?php

$count = 5;

$pireps = PIREPData::getRecentReportsByCount($count);

?>

<table width="725 px" border="1" bordercolor="#FFFFFF">

<thead>

<tr align="center" valign="middle" bgcolor="#7D95AF">

<th>Flight #</th>

<th>Departure</th>

<th>Arrival</th>

<th>Duration</th>

<th>Pilot</th>

<th>Landing Rate</th>

<th>Aircraft</th>

</tr>

</thead>

<tbody>

<?php

if(count($pireps) > 0)

{

foreach ($pireps as $pirep)

{

$pilotinfo = PilotData::getPilotData($pirep->pilotid);

$pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);

echo "<tr>";

echo "<td align=center> $pirep->code $pirep->flightnum </td>";

echo "<td align=center> $pirep->depicao </td>";

echo "<td align=center> $pirep->arricao </td>";

echo "<td align=center> $pirep->flighttime </td>";

echo "<td align=center> $pilotid $pilotinfo->firstname $pilotinfo->lastname </td>";

echo "<td align=center> $pirep->landingrate </td>";

echo "<td align=center> $pirep->aircraft </td>";

echo "</tr>";

}

}

else

{

echo "<tr><td>There are no recent flights!</td></tr>";

}

?>

</table>

</td>

CODE:

<style type="text/css">
#center{
position:absolute;
margin-left:25%;
}
</style>
<div id="center">
<?php
		 $flights = PIREPData::getRecentReportsByCount(5);																																	
		 $string = "";
		 foreach($flights as $flight)
		 {	
						 $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
		 }																																	
?>
<img src="http://www.gcmap.com/map?P=<?php echo $string ?>&MS=wls&MR=900&MX=720x360&PM=b:disc7%2b%25U" width="810px" height="470px" /><br />
					 Maps generated by the <a href="http://www.gcmap.com/">Great Circle Mapper</a> - copyright © <a href="http://www.kls2.com/...om/~karl/">Karl L. Swartz</a>
<!--Start Table-->
<?php
$count = 5;
$pireps = PIREPData::getRecentReportsByCount($count);
?>
<table width="725 px" border="1" bordercolor="#FFFFFF">
<thead>
			 <tr align="center" valign="middle" bgcolor="#7D95AF">
			 <th>Flight #</th>
			 <th>Departure</th>
			 <th>Arrival</th>
			 <th>Duration</th>
			 <th>Pilot</th>
			 <th>Landing Rate</th>
			 <th>Aircraft</th>
			 </tr>
		 </thead>
		 <tbody>
<?php
if(count($pireps) > 0)
{
foreach ($pireps as $pirep)
{
		 $pilotinfo = PilotData::getPilotData($pirep->pilotid);
		 $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);
		 echo "<tr>";
		 echo "<td align=center> $pirep->code $pirep->flightnum </td>";
		 echo "<td align=center> $pirep->depicao </td>";
		 echo "<td align=center> $pirep->arricao </td>";
		 echo "<td align=center> $pirep->flighttime </td>";
		 echo "<td align=center> $pilotid $pilotinfo->firstname $pilotinfo->lastname </td>";
		 echo "<td align=center> $pirep->landingrate </td>";
		 echo "<td align=center> $pirep->aircraft </td>";
		 echo "</tr>";
}
}
else
{
		 echo "<tr><td>There are no recent flights!</td></tr>";
}
?>
</table>
</td>
</div>

Posted

hmmmm, now I am getting this error:

Parse error: syntax error, unexpected $end in /home/luvswavi/public_html/lib/skins/airlines/frontpage_main.tpl on line 66

Line 66 is: $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';

Posted

I got rid of that, but still getting the foreach error.

When I add the CSS for centering the map, it ends up under my footer instead of above it

there is probably some conflict with your existing css, try changing absolute to relative

  • Administrators
Posted

Warning: Invalid argument supplied for foreach()

This generally means that the variable you are trying to loop through is empty or non existent, in your case $flights. Do you have any ACARS data in your table that is current or within the constraint you set in the local config?

After

$flights = ACARSData::GetACARSData();

try putting a

var_dump($flights);

and see what comes out. If there is any data it should show in plain text, if there is none or it shows empty then you must have no current data in your acars table. You should put an if statement prior to the foreach to check for data in the variable and skip the function if it is empty.

if($flights != '') {
//do stuff
}

Also, I am not sure ACARS data is what you are looking for anyway, is it "Latest Flights" or "Current Flights" you are trying to display? If it is latest flights I would use:

$flights = PIREPData::getRecentReportsByCount(5);

  • Administrators
Posted

There are no flights yet, still working on the website before we open

Still not sure if you are looking for "Latest Flights" or "Current Flights" but either way if there is no data (current ACARS or PIREPs) in the system then nothing is going to display and the variable(s) are going to be empty. You will need to use an if statement to check for the empty variable and if it is empty do not create the loop that makes the ICAO string.

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