Jump to content

[SOLVED] Adding Hates Me!


Crew-Portal

Recommended Posts

<?php
$connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$plane = $_POST['plane'];
$time = date("'F j Y, g:i a'");
$strd = $_POST[depart];
$strd = strtoupper($strd);
$stra = $_POST[arrival];
$stra = strtoupper($stra);
$money = round($_POST[distance] + $_POST[distance] / 0.476, 2);
$money2 = '$';
$money_main = '' . $money2 . '' . $money . '';
include_once('random.php');
$sql="INSERT INTO flights (PilotName, FlightDate, AircraftName, NbrPassengers, CargoWeight, DepartureIcaoName, ArrivalIcaoName, TotalDistance, TotalBlockTime, money) VALUES ('CMX-$valid_user', $time, '$_POST[plane]',
 '$passengersrand', '$cargorand Lbs', '$strd', '$stra', '$_POST[distance] NM', '$_POST[hour]:$_POST[minute]', '$money_main');";

$sql2="UPDATE user SET distance=+($_POST[distance]) WHERE username=$valid_user";
$sql3="UPDATE user SET u_money=+($money) WHERE username=$valid_user";
$sql4="UPDATE user SET pax=+($passengersrand) WHERE username=$valid_user";
$sql5="UPDATE user SET cargo=+($cargorand) WHERE username=$valid_user";
$sql6="UPDATE user SET hours=+($_POST[hour].$_POST[minute]) WHERE username=$valid_user";
 $error = $tblstart . 'Flight Sucessfully Posted!' . $tblend;
 include_once($index);
?>

 

This script is SUPPOSED TO Take the money And Distance and stuff of a form and not replace them but Add to them. Like if the original entry is 5 and the new entry is seven it is supposed to make 13. But for some reason it just keeps replacing the original entry with the new entry in the field! Can Someone help me?

Link to comment
Share on other sites

Change these lines:

$sql2="UPDATE user SET distance=+($_POST[distance]) WHERE username=$valid_user";

 

To:

$sql2="UPDATE user SET distance=distance+$_POST['distance'] WHERE username=$valid_user";

 

 

When I do that I Get THis Error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\PIREP\require\action.php on line 403

 

But I do thank you, it is a start... I can see some light at the end of the tunnel. Probable just a few more changes and it will be working

Link to comment
Share on other sites

K I got it!

I used:

<?php
$sql2="UPDATE user SET distance=distance+($_POST[distance]) WHERE username=$valid_user";
$sql3="UPDATE user SET u_money=u_money+($money) WHERE username=$valid_user";
$sql4="UPDATE user SET pax=pax+($passengersrand) WHERE username=$valid_user";
$sql5="UPDATE user SET cargo=cargo+($cargorand) WHERE username=$valid_user";
$sql6="UPDATE user SET hours=hours+($_POST[hour].$_POST[minute]) WHERE username=$valid_user";
?>

 

So...

 

TOPIC SOLVED!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.