...

View Full Version : Update Page not updating



kenwvs
08-11-2006, 10:37 AM
I have a form that appears to work the way it is suppose to until I hit the submit button on the form....then it won't update.

I have a form where you key in an ID number, which then takes you to another form with all of the information. You can add info to a couple of fields, which are the ones I want to update to the database, but they are not being updated.

If these fields don't have any info in them, should it be update, or should it be insert (or is insert only for new rows in a table)

I have had to comment out the following code, or the form was automatically giving me the successfully updated comment.

if (!isset($_POST['Submit'])){ I have also commented out the } at the other end of the code.

here is the update code I am using.

Purchase and Comment are both fields in the database, and are set to not null. These fields are not called to insert in the original form as they are not used at that point.


<BR><BR>
<div><input type="submit" name="Submit" value="Update Work Order"><BR><BR><BR><BR></div>
</form>
<?php
exit();

} else
{
$Work = $_POST["Work"];
$Sched = $_POST["Sched"];
$Name = $_POST["Tech"];
$Site = $_POST["Site"];
$Serial = $_POST["Serial"];
$Hours = $_POST["Hours"];
$Starts = $_POST["Starts"];
$Issue = $_POST["Issue"];
$Severity = $_POST["Severe"];
$Resolution = $_POST["Resolve"];
$Assistance = $_POST["Assist"];
$PartsA = $_POST["PartsA"];
$PartsB = $_POST["PartsB"];
$PartsC = $_POST["PartsC"];
$PartsD = $_POST["PartsD"];
$PartsE = $_POST["PartsE"];
$PartsF = $_POST["PartsF"];
$PartsG = $_POST["PartsG"];
$Safety = $_POST["Safe"];
$Image1 = $_FILE["Image1"];
$Image2 = $_FILE["Image2"];
$Image3 = $_FILE["Image3"];
$Image4 = $_FILE["Image4"];
$Purchase = $_POST["Purchase"];
$Comment = $_POST["Comment"];
$Remarks = $_POST["Remarks"];

mysql_query ("UPDATE `workorder` set Purchase = '$Purchase' , Comment = '$Comment' where
work = 'Work'")or die(mysql_error());
echo "This Work Order has been Updated Successfully";

//}
?>

raf
08-11-2006, 01:26 PM
If these fields don't have any info in them, should it be update, or should it be insert (or is insert only for new rows in a table)
an insert-statement will (try to) create a new row.

i don't realy uderstand what you are asking for...

kenwvs
08-11-2006, 04:23 PM
I guess what I am asking is you can help me figure out why this UPDATE stateent does't work. It does everything except UPDATE the database.

Ken

raf
08-11-2006, 04:31 PM
is the "This Work Order has been Updated Successfully" shown?
are there actualy records in that table where "work = 'Work'" is true?
or did you intend to have "work = '$Work'" there?

kenwvs
08-11-2006, 04:43 PM
I had to go back and see if the success statement came up and it doesn't

I believe the work = $work statement is correct. I have it set up where the form data you are seeing is obtained by keying in the workorder (work) number. So I am only wanting it to update the row that has that particular number. I do have data in already with that work order number

kenwvs
08-11-2006, 04:43 PM
I should have said I am not getting any errors, it returns to the form in a blank state........

kenwvs
08-11-2006, 04:46 PM
Now you have me thinking about the work = $work.... I have a form where you input the workorder # where the field is called contact. It then takes you to this form with all the data in it. On the form with all the data, the workorder number is called "work", but on the original form it is referred to as Contact

arnyinc
08-11-2006, 08:39 PM
Now you have me thinking about the work = $work.... I have a form where you input the workorder # where the field is called contact. It then takes you to this form with all the data in it. On the form with all the data, the workorder number is called "work", but on the original form it is referred to as Contact

You don't have work=$work. You have work='Work'. Add some echo statements to make sure you are getting into the else clause and it isn't stopping on your exit();

kenwvs
08-11-2006, 09:29 PM
arnyinc - are you referring to the capital "W", or are you saying I shouldn't have the $ sign. There are some echo statements in the code earlier where I should get either success or failure remarks, but I am not getting either.

[code]
</div> <!--Close Header-->
<div id="topnav">
<BR><BR><BR><BR> <!--Open Top Navigation-->
<BODY BGCOLOR="gainsboro">
<?php
include_once "myconnect.php";
$Contact = $_POST['Contact'];
$query=mysql_query("SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
Safety, Image1, Image2, Image3, Image4 FROM workorder WHERE Work='$Contact'");
if (!$query) {
echo "YOU HAVE AN ERROR IN YOUR QUERY!<br>\n";
echo mysql_error();
} else {
$workorderInfo = mysql_fetch_assoc($query);
}

//this is just for testing
if (mysql_num_rows($query) == 0) {
echo "No rows returned from table workorder using ID = '$Work'<br>\n";
}
?>
<?php
// womanager.php
//if (!isset($_POST['Submit'])){
?>
]/code]

arnyinc
08-11-2006, 09:35 PM
There are some echo statements in the code earlier where I should get either success or failure remarks, but I am not getting either.


That's probably why your update isn't working if it isn't even executing the first part of your script correctly. Troubleshoot that first.

kenwvs
08-12-2006, 01:59 AM
The first part of the script does work as it is returning the results from the database.

When I put in the number of the work order I want to review, I ge all th results in a form. Afte I add info to the two new categories (they are not on the original form) it doesn't update this new data.

Would this be the wrong function seeing as these 2 items were not on the original form, but this row is in the database table. I have these set to not null in the table. I don't now what it is called, but should I have these 2 fields listed in the code on the original form where it gives the command to save into the DB.(the thing I don't what it is called is shown below, only cause I don't know the name..... sorry for my ignorance.



} else
{
$Work = $_POST["Work"];
$Sched = $_POST["Sched"];
$Name = $_POST["Tech"];
$Site = $_POST["Site"];
$Serial = $_POST["Serial"];
$Hours = $_POST["Hours"];
$Starts = $_POST["Starts"];
$Issue = $_POST["Issue"];
$Severity = $_POST["Severe"];
$Resolution = $_POST["Resolve"];
$Assistance = $_POST["Assist"];
$PartsA = $_POST["PartsA"];
$PartsB = $_POST["PartsB"];
$PartsC = $_POST["PartsC"];
$PartsD = $_POST["PartsD"];
$PartsE = $_POST["PartsE"];
$PartsF = $_POST["PartsF"];
$PartsG = $_POST["PartsG"];
$Safety = $_POST["Safe"];
$Purchase = $_POST["Purchase"];
$Comment = $_POST["Comment"];
$Remarks = $POST_["Remarks"];
}
mysql_query ("Insert into `workorder`(Work, Sched, Name, Hours, Starts, Issue, Severity, Resolution, Assistance,
PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG, Safety) VALUES
('$Work', '$Sched', '$Name', '$Hours', '$Starts', '$Issue', '$Severity', '$Resolution', '$Assistance', '$PartsA',
'$PartsB', '$PartsC', '$PartsD', '$PartsE','$PartsF', '$PartsG', '$Safety')")or die(mysql_error());
echo "This Work Order has been Updated Successfully";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum