Guest Posted October 15, 2011 Report Share Posted October 15, 2011 Hey there, My Friend and I created a java GUI application which reads our schedules database and lets the user search for a flight and gets the right data ready. You then click on 'Start Flight' and after you fly it, click on 'End Flight'. (Note that this is made for FlightGear Free and Open Source Flight Simulator) Then the application reads the flight time, fuel used and the route flown and posts the following variables to a temporary link (www.merlionvirtual.clubos.net/auto/scheduled.php) Now, there's nothing in the php file, so what do I put there so it can submit the PIREP with the posted data? pilotidpassword depicao arricao flightnum aircraft flighttime route fuel Thanks a LOT for your help. Quote Link to comment Share on other sites More sharing options...
Tom Posted October 15, 2011 Report Share Posted October 15, 2011 If you want to use it to submit PIREPs to phpVMS you should have a look at the files for kACARS etc. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 15, 2011 Report Share Posted October 15, 2011 But kAcars has to do with bids and stuff, I just want to submit a direct PIREP. Can anyone give me the code? Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 15, 2011 Report Share Posted October 15, 2011 Look at the fspx module for help. It uses $_POST variables for PIREP submission core/modules/acars/fspax.php Quote Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2011 Report Share Posted October 16, 2011 Would this work? (The file is in the ACARS folder next to fspax.php) # Defining some string that we don't get/need from the APS $comment .= 'Submitted by the Automatic PIREP System'; $code .= 'MIA'; # This must be changed for the VA using the APS # Getting POST Data from the client and compiling it for submission $data = array( 'pilotid'=>$_POST['pilotid'], 'code'=>$code, 'flightnum'=>$_POST['flightnum'], 'depicao'=>$_POST['depicao'], 'arricao'=>$_POST['arricao'], 'aircraft'=>$_POST['aircraft'], 'route'=>$_POST['route'], 'flighttime'=>$_POST['flighttime'], 'submitdate'=>'NOW()', 'fuelused'=>$_POST['fuel'], 'comment'=>$comment); $ret = ACARSData::FilePIREP($pilotid, $data); The login is managed directly with the java client and about aircraft, does it have to be the number or the registration? If it's the number, the java sends the registration, how do I convert it? Thanks! Quote Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2011 Report Share Posted October 16, 2011 Nah, I just directly wrote to the database instead of going through all that php trouble. Works fine now, thanks anyway. Oh and I was trying to figure out the login part. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2011 Report Share Posted October 16, 2011 Hmm, I continued with the php too so I can also get to know a bit more about it. Here's what I came up with now, but there's an error. First of all, here's the code : <?php $con = mysql_connect("localhost", "merlio2_merlion", " "); if(!$con) { die('Could not Connect! : ' . mysql_error()); } mysql_select_db("merlio2_merlion", $con); $reg_sent = $_POST['aircraft']; $flightnum = $_POST['flightnum']; $aircraftdata = "SELECT id, maxpax FROM phpvms_aircraft WHERE registration=$reg_sent"; $aircraft = 'id'; $load = 'maxpax'; $scheduledata = "SELECT price, distance FROM phpvms_schedules WHERE flightnum=$flightnum"; $price = 'price'; $distance = 'distance'; $gross = $price * $load; $pilotpay = $gross / 10; $fuelprice = $_POST[fuel] * 5.1; $revenue = $gross - $fuelprice; $sql = "INSERT INTO phpvms_pireps (pilotid, code, flightnum, depicao, arricao, route, aircraft, flighttime, submitdate, fuelused, fuelunitcost, source, load, distance, gross, pilotpay, fuelprice, flighttype, revenue) VALUES ('$_POST[pilotid]', 'MIA', '$_POST[flightnum]', '$_POST[depicao]', '$_POST[arricao]', '$_POST[route]', '$aircraft', '$_POST[flighttime]', 'NOW()', '$_POST[fuel]', '5.1', 'VSA-APS', '$load', '$distance', '$gross', '$pilotpay', '$fuelprice', 'P', '$revenue')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "PIREP Successfully submitted! Thank you for using Virtual Star Alliance's Automatic PIREP system"; mysql_close($con) ?> And here's the error : Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'load, distance, gross, pilotpay, fuelprice, flighttype, revenue) VALUES ('', 'MI' at line 1 Can someone please help me? Again... Quote Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2011 Report Share Posted October 16, 2011 Hey, Found the error by going through My MySQL textbook. Seems that "LOAD" is a reserved command so I can't use it directly. I've corrected that by using back quotations (`). eg. using `load` instead of load. Thanks anyway, and the time-stamp is also an error but I fixed that with date() function in php. For those (well, this is only for flightgear) interested, let me know and I'll paste the java GUI and the php source code up here. Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 16, 2011 Administrators Report Share Posted October 16, 2011 Don't write directly to the database. You'll lose any data integrity, and you'll lose things in updates (like in the betas, a ton of code has changed in the pirep submission process). And all that financial code is changing/changed You need to use the ACARSData::filePIREP function. Read through here: http://forum.phpvms....html?category=6 Looks through this code: https://github.com/n...sacars.php#L386 And look how each variable is formatted so then it's submitted Quote Link to comment Share on other sites More sharing options...
Guest Posted October 17, 2011 Report Share Posted October 17, 2011 I've tried that but the java GUI returns "ACARSdata class not found". Quote Link to comment Share on other sites More sharing options...
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.