Hallo alle zusammen.
habe einen Vorhandenen Code umgeändert. Leider schreibt er mir die Daten nicht in die DB. Habe die neuen Skripts bereits mit händischen Daten ausprobiert u´nd sie Funktionieren alle. Jedoch beim zusammensetzen muss ich irgendwo einen Fehler gemacht haben.
den jetzt schreibt die PHP in keine DB mehr ein und es steht diese Meldung im Spiel: „Error - The web site didn’t replied“.
Hoffe Ihr könnt mir folgen.
Hier mal der Code das fett geschriebene ist das abgeänderte
<?php define("FSP", 1);# setting.php contain MySQL database setting and other setting it contain also the FSP UNIT SETTING require("FsPadmin/setting.php"); # common.php do the connexion to MySQL the value $databaseconnexion is set to true if the connexion is okay require("FsPadmin/common.php"); ////////////////////////////////////////////////////////////////// // FsP Asked connexion // ------------------- // When the user call the menu FsP check the connexion // it's time to check username, password and give unit setup ////////////////////////////////////////////////////////////////// if($\_POST['FsPAskConnexion']=="yes") { // the value "$databaseconnexion" is set to true in common.php if the SQL connexion is ok if($databaseconnexion==FALSE) { echo "#Answer# Error - unable to connect to mySQL database;"; return; } // check username and password if($query = "SELECT \* FROM user\_profile WHERE UserName='$\_POST[UserName]' and Password='$\_POST[Password]'") $result=@mysql\_query($query);if(!$result){echo "#Answer# SQL Error - ".mysql\_error();return;} if(mysql\_num\_rows($result)==0) { echo "#Answer# Error - Username don't exist or wrong password;"; return; } //If we are here, username, password and connexion to SQL database is ok so we reply it's ok and we give the units we want //that FsP send to us, those unit are defined in the setting.php, you can modify them while going to ADMIN part. // this will also send the welcome message to the user's FSP export dialog. echo "#Answer# Ok - connected;"; echo "Weight=$cfg[WeightUnit] Dist=$cfg[DistanceUnit] Speed=$cfg[SpeedUnit] Alt=$cfg[AltUnit] Liqu=$cfg[LiquidUnit]"; printf("#welcome#%s#endwelcome#",$cfg['welcome\_message']); WriteDebug(); exit(); } ////////////////////////////////////////////////////////////////// // FsP requested to register one flight // ------------------------------------ // you MUST reply with an #answer# as listed at end of function // You can add more error code but it must start with "#answer#" // and end with a ";" this error code will be showed to the user. // DON'T CHANGE the "#Answer# Ok - Saved;" and "#Answer#exist#" // because FsP absolutely need them. ////////////////////////////////////////////////////////////////// if($\_POST['FsPAskToRegister']=="yes") { // the value "$databaseconnexion" is set to true in common.php if the connexion is ok if($databaseconnexion==FALSE) { echo "#Answer# Error - unable to connect to mySQL database;"; return; } // check username and password again to avoid hacking if($query = "SELECT \* FROM user\_profile WHERE UserName='$\_POST[UserName]' and Password='$\_POST[Password]'") $result=@mysql\_query($query);if(!$result){echo "#Answer# SQL Error - ".mysql\_error();return;} if(mysql\_num\_rows($result)==0) { echo "#Answer# Error - Username don't exist or wrong password;"; return; } // check the database to see if the flight was registered already if($query = "SELECT \* FROM flights WHERE UserName='$\_POST[UserName]' and FlightId='$\_POST[FlightId]' and TotalBlockTime='$\_POST[TotalBlockTime]' and ArrivalLocalHour='$\_POST[ArrivalLocalHour]'") $result=@mysql\_query($query);if(!$result){echo "#Answer# SQL Error - ".mysql\_error();return;} if(mysql\_num\_rows($result)\>0) { echo "#Answer#exist# Error - Flight already exist in database;"; //this message error should NOT be modified at all... return; } // add slashes for idiot server that dumbly disabled magic\_quote\_gpc if(!get\_magic\_quotes\_gpc()) { $\_POST['PilotPenalityText'] =addslashes($\_POST['PilotPenalityText']); $\_POST['PassengersOpinionText'] =addslashes($\_POST['PassengersOpinionText']); $\_POST['FailureText'] =addslashes($\_POST['FailureText']); $\_POST['CasualtiesText'] =addslashes($\_POST['CasualtiesText']); $\_POST['PilotBonusText'] =addslashes($\_POST['PilotBonusText']); } // ALL IS OK REGISTER THE FLIGHT **$starttreibstoff=$\_POST[StartFuelQuantity]; $landetreibstoff=$\_POST[EndFuelQuantity]; $sumcargo=$\_POST[CargoWeight]; $sumpassenger=$\_POST[NbrPassengers]; $sumdistanz=$\_POST[TotalDistance]; $Airtime=$\_POST[TotalAirbornTime];** $query = "INSERT INTO flights(id,datestamp,UserName,CompanyName,PilotName,FlightId,OnlineNetworkNbr,FlightDate,AircraftName,AircraftType,NbrPassengers,CargoWeight,Mtow,StartAircraftWeight,EndAircraftWeight,StartFuelQuantity,EndFuelQuantity,DepartureIcaoName,ArrivalIcaoName,DepartureLocalHour,ArrivalLocalHour,DepartureGmtHour,ArrivalGmtHour,TotalBlockTime,TotalBlockTimeNight,TotalAirbornTime,TotalTimeOnGround,TotalDistance,MaxAltitude,CruiseSpeed,CruiseMachSpeed,CruiseTimeStartSec,CruiseTimeStopSec,CruiseFuelStart,CruiseFuelStop,LandingSpeed,LandingPitch,TouchDownVertSpeedFt,CaptainSentMayday,CrashFlag,FlightResult,PassengersOpinion,PassengersOpinionText,FailureText,CasualtiesText,PilotBonusText,BonusPoints,PilotPenalityText,PenalityPoints) VALUES('',now(),'$\_POST[UserName]','$\_POST[CompanyName]','$\_POST[PilotName]','$\_POST[FlightId]','$\_POST[OnlineNetworkNbr]','$\_POST[FlightDate]','$\_POST[AircraftName]','$\_POST[AircraftType]', **'$sumpassenger'** ,' **$sumcargo'** ,'$\_POST[Mtow]','$\_POST[StartAircraftWeight]','$\_POST[EndAircraftWeight]',' **$starttreibstoff'** ,' **$landetreibstoff'** ,'$\_POST[DepartureIcaoName]','$\_POST[ArrivalIcaoName]','$\_POST[DepartureLocalHour]','$\_POST[ArrivalLocalHour]','$\_POST[DepartureGmtHour]','$\_POST[ArrivalGmtHour]','$\_POST[TotalBlockTime]','$\_POST[TotalBlockTimeNight]','$Airtime','$\_POST[TotalTimeOnGround]',' **$sumdistanz'** ,'$\_POST[MaxAltitude]','$\_POST[CruiseSpeed]','$\_POST[CruiseMachSpeed]','$\_POST[CruiseTimeStartSec]','$\_POST[CruiseTimeStopSec]','$\_POST[CruiseFuelStart]','$\_POST[CruiseFuelStop]','$\_POST[LandingSpeed]','$\_POST[LandingPitch]','$\_POST[TouchDownVertSpeedFt]','$\_POST[CaptainSentMayday]','$\_POST[CrashFlag]','$\_POST[FlightResult]','$\_POST[PassengersOpinion]','$\_POST[PassengersOpinionText]','$\_POST[FailureText]','$\_POST[CasualtiesText]','$\_POST[PilotBonusText]','$\_POST[BonusPoints]','$\_POST[PilotPenalityText]','$\_POST[PenalityPoints]')"; if(!@mysql\_query($query)){echo "#Answer# SQL Error - ".mysql\_error();return;} **//Abruf der benoetigten Daten $Zeit = time\_to\_sec($Airtime)/'3600'; $query = "SELECT sec\_to\_time(sum(time\_to\_sec(TotalBlockTime))) FROM flights WHERE UserName = '$pilot'".$condition; $result=mysql\_query($query); $TFT = number\_format(mysql\_result($result,0)); $query = "SELECT Verdienst FROM rank WHERE hours \>= $TFT limit 1".$condition; $result=mysql\_query($query); $Verdienst = mysql\_result($result,0); $query = "SELECT Geld FROM user\_profile WHERE UserName = '$pilot'".$condition; $result=mysql\_query($query); $Pilotgeld = mysql\_result($result,0); $query = "SELECT Treibstoffausgaben FROM Finanzen WHERE id = '1'".$condition; $result=mysql\_query($query); $Treibstoffausgaben = mysql\_result($result,0); $query = "SELECT Cargoeinnahmen FROM Finanzen WHERE id = '1'".$condition; $result=mysql\_query($query); $Cargoeinnahmen = mysql\_result($result,0); $query = "SELECT Passengereinnahmen FROM Finanzen WHERE id = '1'".$condition; $result=mysql\_query($query); $Passengereinnahmen = mysql\_result($result,0); $Treibstoffverbrauch=$starttreibstoff-$landetreibstoff; //Berechnung des Erwirtschafteten Geldes vom Flug $Passengerticket=round($sumpassenger\*$sumdistanz\*'897391304347826'/'1000000000000000'); $Cargoticket=round($sumcargo\*$sumdistanz\*'558563909441878'/'100000000000000000'); $Fuelticket=round($Treibstoffverbrauch\*'1218059826670394'/'1000000000000000'); //Errechnen des neuen Piloten Kontostand fuer Piloten $Pilotenkosten=round($Zeit\*$Verdienst); echo $Pilotenkosten?\>€ Pilotenkosten ; $geldneu=$Pilotenkosten+$Pilotgeld; echo $geldneu?\>€ neuer geldstand ; //Errechnen und UPDATE des neuen VA Kontostand fuer Piloten $query = "SELECT Pilotenausgaben FROM Finanzen WHERE id='1'".$condition; $result=mysql\_query($query); $Pilotenausgaben = mysql\_result($result,0); mysql\_query("Update user\_profile SET geld = '$geldneu' WHERE UserName = '$pilot'"); //Update VA geld $VAPilot=$Pilotenausgaben+$Pilotenkosten; $VAFuel=$Treibstoffausgaben+$Fuelticket; $VACargo=$Cargoeinnahmen+$Cargoticket; $VAPassenger=$Passengereinnahmen+$Passengerticket; mysql\_query("Update Finanzen SET Pilotenausgaben = '$VAPilot' WHERE id = '1'"); mysql\_query("Update Finanzen SET Treibstoffausgaben = '$VAFuel' WHERE id = '1'"); mysql\_query("Update Finanzen SET Cargoeinnahmen = '$VACargo' WHERE id = '1'"); mysql\_query("Update Finanzen SET Passengereinnahmen = '$VAPassenger' WHERE id = '1'");** // PENALITY DISABLED BIT // there is one more value that exist and is not recorded, this value contain the bit of penality disabled // by the config/more\_option.cfg, this value can help you to check that your users don't cheat // if this value is not 0 there was one or more penality disabled, you can perform bit test to know wich one. //if($\_POST[BitsPenalityDisabled]\>0) // mean one penality was disabled // if we are here all is ok, reply that the fligth was registered echo "#Answer# Ok - Saved;"; WriteDebug(); exit(); } ////////////////////////////////////////////////////////////////// // DEBUG FUNCTION // ------------------------------------ // If you use localhost, FsP can also send report to your // localhost, in this case the $\_POST value send by FsP will // be written in a "debug.txt" file // THIS WILL NOT SHOW WHEN ONLINE // To test in localhost see directory FsPassengers/config\_va/ // create a new cfg here with any name, copy the data of the // VaFsPassengers.cgf into it and change the data accordingly to // your setting. (ie: url like http://localhost/MyTest ) ////////////////////////////////////////////////////////////////// function WriteDebug() { if($\_SERVER['REMOTE\_ADDR']=="127.0.0.1") { if($fp=fopen("Debug.txt","ab")) { ob\_start(); print\_r($\_POST); $text = ob\_get\_contents(); ob\_end\_clean(); $text = str\_replace("\n","\r\n",$text); $len=strlen($text); fputs($fp,$text,$len); fclose($fp); echo $text; } } } ?\>