Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update Page not updating

    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.
    Code:
    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.

    Code:
    <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";
    
    //}
    ?>

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by kenwvs
    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...
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I should have said I am not getting any errors, it returns to the form in a blank state........

  • #7
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #8
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Quote Originally Posted by kenwvs
    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();

  • #9
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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]

  • #10
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Quote Originally Posted by kenwvs
    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.

  • #11
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


    Code:
    } 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";


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •