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
https://forums.phpfreaks.com/topic/67096-solved-adding-hates-me/
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

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

Archived

This topic is now archived and is closed to further replies.

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