/    Sign up×
Community /Pin to ProfileBookmark

I have a form as follows.

These is an input called ‘boxes’ which should contain the total of 4 other inputs (‘large’, ‘medium’, ‘small’ and ‘tails’).

Before I update mySQL data I want to check the following:

boxes = (large + medium + small + tails)

Here is part of the code I am using without success:

[CODE]
if (isset($_POST[‘submit’])){
$boxes = $_POST[“boxes”];
$large = $_POST[“large”];
$medium = $_POST[“medium”];
$smalll = $_POST[“small”]; // smalll becasue small is a keyword
$tails = $_POST[“tails”];

$message = NULL;

if (empty($_POST[‘boxes’])) {
$boxes = FALSE;
$message .= ‘<p>You forgot to enter boxes!</p>’;
}else{
$boxes = $_POST[‘boxes’];
}

$totalBoxes = $large + $medium + $smalll + $tails;

if( $totalBoxes <> $boxes){
$message = ‘<p>The number of boxes does not add up!</p>’;
$totalBoxes = FALSE;
}

if ($boxes && $totalBoxes) {
require (‘cgi-bin/mysql_connect.php’); //connect to the db
$queryDate = sprintf(“%04d-%02d-%02d”, $year, $month, $day);

$sql = “UPDATE vessels SET boxes = ‘$boxes’, large=’$large’, medium=’$medium’, small=’$smalll’, tails=’$tails’, boxweight =’$boxweight’, dipped = ‘$dipped’, dateLanded = ‘$queryDate’ WHERE id=$id”;

$result = mysql_query($sql);
header(“Location: vessels.php”);
mysql_close(); // Close the database connection.
}
}

[/CODE]

The problem is this:
Even when I put 100 into boxes, 50 into large, 10 into medium, 10 into small and 30 into tails it still says ‘Totals do not add up”

Can anyone advise why it is not working?

THanks,

J

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@dbrandonOct 25.2007 — Instead of

[code=php]if( $totalBoxes <> $boxes){[/code]

try

[code=php]if( $totalBoxes != $boxes){[/code]

See if that works ?

David.
Copy linkTweet thisAlerts:
@john_nobleauthorOct 25.2007 — It's now working.


Thanks,

J
×

Success!

Help @john_noble spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...