Forum Moderators: coopster
if (isset($_POST['change'])): //if updates have been entered and need to be
$date=$_POST['date'];
$maincourse=$_POST['maincourse'];
$veggie=$_POST['veggie'];
$veggie2=$_POST['veggie2'];
$fruit=$_POST['fruit'];
$dessert=$_POST['dessert'];
$drink=$_POST['drink'];
$bread=$_POST['bread'];
$fromwhere=$_POST['fromwhere'];
$xdate=$_POST['xdate'];
$zdate=$_POST['zdate'];
$ok1 = @mysql_query("UPDATE $fromwhere SET
day='$day',
maincourse='$maincourse',
veggie='$veggie',
veggie2='$veggie2',
fruit='$fruit',
bread='$bread',
dessert='$dessert',
drink='$drink'
WHERE id='$id'");
if ($ok1) {
echo '<p>item updated successfully!</p>';
} else {
echo '<p>Error updating item in database!<br />'.
'Error: ' . mysql_error() . '</p>';
}
WHERE id='$id'") or trigger_error(mysql_error());
This will give you an idea on if your program is erroring on the mysql query and on what part of the query.
The reason your program always says it's successful is because you have it checking if a variable has any information in it just after you assign it all kinds of information. It will always be true.
If you want to check to see if the query actually completes, do an if statement on the mysql_affected_rows().
if (mysql_affect_rows > 0) instead of $ok1 .
It's mysql_affected_rows() not what I put above
On your problem, how are you getting the date? Is the date row in your table set to DATE in MySQL?
If so, it needs to fit a certain structure.
It's YYYY-MM-DD
[dev.mysql.com...]
EDIT: Didn't notice you had it that way already. I would make sure it's submitting correctly though.