title: Reactjs- Edit form not updating the database table
body: <p>I am trying to create an edit form that will enable me update data in a table.
  When I click on the 'edit' button on my table it correctly redirects me to the edit form and data is also being correctly filled into the respective fields of the form, no issue there.</p>
  <p>The only issue I am facing is that when I click on 'edit' on the form it does not update anything. I have used then same format for other forms and it works correctly but in this particular form I am having this issue.</p>
  <p>Maybe there is something I may have done wrong and am unable to detect it so if you could help me see what I have done wrong that would be a real timesaver. I have looked at it for 2 days but am unable to see what I have done wrong.</p>
  <p><strong>editticket.js:</strong></p>
  <pre><code>import axios from &quot;axios&quot;;
  import { React, useState, useEffect } from &quot;react&quot;;
  import { useHistory, withRouter } from &quot;react-router-dom&quot;;
  
  function TicketMaster_Edit(props) {
    const [CmpnyCode, setCmpnyCode] = useState(&quot;&quot;);
    const [DocNo, setDocNo] = useState(&quot;&quot;);
    const [DocDate, setDocDate] = useState(&quot;&quot;);
    const [DocType, setDocType] = useState(&quot;&quot;);
    const [AccCode, setAccCode] = useState(&quot;&quot;);
    const [AccName, setAccName] = useState(&quot;&quot;);
    const [OtherTradingName, setOtherTradingName] = useState(&quot;&quot;);
    const [MobileNo, setMobileNo] = useState(&quot;&quot;);
    const [Email, setEmail] = useState(&quot;&quot;);
    const [RequestType, setRequestType] = useState(&quot;&quot;);
    const [Description, setDescription] = useState(&quot;&quot;);
    const [ServiceCover, setServiceCover] = useState(&quot;&quot;);
    const [ContractDetail, setContractDetail] = useState(&quot;&quot;);
    const [BillingDetail, setBillingDetail] = useState(&quot;&quot;);
    const [OtherDetail, setOtherDetail] = useState(&quot;&quot;);
    const [AssignedTo, setAssignedTo] = useState(&quot;&quot;);
    const [VendorObservation, setVendorObservation] = useState(&quot;&quot;);
    const [Conclusion, setConclusion] = useState(&quot;&quot;);
    const [StatusType, setStatusType] = useState(&quot;&quot;);
    const [RegistrationDate, setRegistrationDate] = useState(&quot;&quot;);
    const [ClosingDate, setClosingDate] = useState(&quot;&quot;);
    const [RegisteredBy, setRegisteredBy] = useState(&quot;&quot;);
    const [ClosedBy, setClosedBy] = useState(&quot;&quot;);
    const [CustomerAttachmentLinks, setCustomerAttachmentLinks] = useState(&quot;&quot;);
    const [VendorAttachmentLinks, setVendorAttachmentLinks] = useState(&quot;&quot;);
    const [RecordChanged, setRecordChanged] = useState(&quot;&quot;);
    const [DateEntered, setDateEntered] = useState(&quot;&quot;);
  
    const history = useHistory();
  
    const argu = props.match.params.DocNo;
  
    useEffect(() =&gt; {
      axios.get(&quot;http://localhost:8000/getdocno/&quot; + argu).then((response) =&gt; {
        setCmpnyCode(response.data[0].CmpnyCode);
        setDocNo(response.data[0].DocNo);
        setDocType(response.data[0].DocType);
        setDocDate(response.data[0].DocDate);
        setAccCode(response.data[0].AccCode);
        setAccName(response.data[0].AccName);
        setOtherTradingName(response.data[0].OtherTradingName);
        setMobileNo(response.data[0].MobileNo);
        setEmail(response.data[0].Email);
        setRequestType(response.data[0].RequestType);
        setDescription(response.data[0].Description);
        setServiceCover(response.data[0].SeviceCover);
        setContractDetail(response.data[0].ContractDetail);
        setBillingDetail(response.data[0].BillingDetail);
        setOtherDetail(response.data[0].OtherDetail);
        setAssignedTo(response.data[0].AssignedTo);
        setVendorObservation(response.data[0].VendorObservation);
        setConclusion(response.data[0].Conclusion);
        setStatusType(response.data[0].StatusType);
        setRegistrationDate(response.data[0].RegistrationDate);
        setClosingDate(response.data[0].ClosingDate);
        setRegisteredBy(response.data[0].RegisteredBy);
        setClosedBy(response.data[0].ClosedBy);
        setCustomerAttachmentLinks(response.data[0].CustomerAttachmentLinks);
        setVendorAttachmentLinks(response.data[0].VendorAttachmentLinks);
        setRecordChanged(response.data[0].RecordChanged.data[0]);
        setDateEntered(response.data[0].DateEntered);
        console.log(response.data);
      });
    }, [argu]);
  
    const editData = () =&gt; {
      axios.put(&quot;http://localhost:8000/upticketmst/&quot; + argu, {
        CmpnyCode,
        DocNo,
        DocDate,
        DocType,
        AccCode,
        AccName,
        OtherTradingName,
        MobileNo,
        Email,
        RequestType,
        Description,
        ServiceCover,
        ContractDetail,
        BillingDetail,
        OtherDetail,
        AssignedTo,
        VendorObservation,
        Conclusion,
        StatusType,
        RegistrationDate,
        ClosingDate,
        RegisteredBy,
        ClosedBy,
        CustomerAttachmentLinks,
        VendorAttachmentLinks,
        RecordChanged,
        DateEntered,
      });
      history.push(&quot;/ticketmst&quot;);
    };
  
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;div className=&quot;auth-wrapper&quot;&gt;
          &lt;div className=&quot;auth-inner&quot;&gt;
            &lt;form onSubmit={() =&gt; editData()}&gt;
              &lt;h3&gt;Ticket Master&lt;/h3&gt;
              &lt;div className=&quot;form-class8&quot;&gt;
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;CmpnyCode&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;CmpnyCode&quot;
                    value={CmpnyCode}
                    onChange={(e) =&gt; {
                      setCmpnyCode(e.target.value);
                    }}
                    name=&quot;CmpnyCode&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;DocNo&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;DocNo&quot;
                    value={DocNo}
                    onChange={(e) =&gt; {
                      setDocNo(e.target.value);
                    }}
                    name=&quot;DocNo&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;DocDate&lt;/label&gt;
                  &lt;input
                    type=&quot;date&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;DocDate&quot;
                    value={DocDate}
                    onChange={(e) =&gt; {
                      setDocDate(e.target.value);
                    }}
                    name=&quot;DocDate&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;DocType&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;DocType&quot;
                    value={DocType}
                    onChange={(e) =&gt; {
                      setDocType(e.target.value);
                    }}
                    name=&quot;DocType&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;AccCode&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;AccCode&quot;
                    value={AccCode}
                    onChange={(e) =&gt; {
                      setAccCode(e.target.value);
                    }}
                    name=&quot;AccCode&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;AccName&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;AccName&quot;
                    value={AccName}
                    onChange={(e) =&gt; {
                      setAccName(e.target.value);
                    }}
                    name=&quot;AccName&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;OtherTradingName&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;OtherTradingName&quot;
                    value={OtherTradingName}
                    onChange={(e) =&gt; {
                      setOtherTradingName(e.target.value);
                    }}
                    name=&quot;OtherTradingName&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;MobileNo&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;MobileNo&quot;
                    value={MobileNo}
                    onChange={(e) =&gt; {
                      setMobileNo(e.target.value);
                    }}
                    name=&quot;MobileNo&quot;
                  /&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div className=&quot;form-class8&quot;&gt;
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;Email&lt;/label&gt;
                  &lt;input
                    type=&quot;email&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;Email&quot;
                    value={Email}
                    onChange={(e) =&gt; {
                      setEmail(e.target.value);
                    }}
                    name=&quot;Email&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;RequestType&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;RequestType&quot;
                    value={RequestType}
                    onChange={(e) =&gt; {
                      setRequestType(e.target.value);
                    }}
                    name=&quot;RequestType&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;Description&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;Description&quot;
                    value={Description}
                    onChange={(e) =&gt; {
                      setDescription(e.target.value);
                    }}
                    name=&quot;Description&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;ServiceCover&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;ServiceCover&quot;
                    value={ServiceCover}
                    onChange={(e) =&gt; {
                      setServiceCover(e.target.value);
                    }}
                    name=&quot;ServiceCover&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;ContractDetail&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;ContractDetail&quot;
                    value={ContractDetail}
                    onChange={(e) =&gt; {
                      setContractDetail(e.target.value);
                    }}
                    name=&quot;ContractDetail&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;BillingDetail&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;BillingDetail&quot;
                    value={BillingDetail}
                    onChange={(e) =&gt; {
                      setBillingDetail(e.target.value);
                    }}
                    name=&quot;BillingDetail&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;OtherDetail&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;OtherDetail&quot;
                    value={OtherDetail}
                    onChange={(e) =&gt; {
                      setOtherDetail(e.target.value);
                    }}
                    name=&quot;OtherDetail&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;AssignedTo&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;AssignedTo&quot;
                    value={AssignedTo}
                    onChange={(e) =&gt; {
                      setAssignedTo(e.target.value);
                    }}
                    name=&quot;AssignedTo&quot;
                  /&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div className=&quot;form-class8&quot;&gt;
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;VendorObservation&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;VendorObservation&quot;
                    value={VendorObservation}
                    onChange={(e) =&gt; {
                      setVendorObservation(e.target.value);
                    }}
                    name=&quot;VendorObservation&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;Conclusion&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;Conclusion&quot;
                    value={Conclusion}
                    onChange={(e) =&gt; {
                      setConclusion(e.target.value);
                    }}
                    name=&quot;Conclusion&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;StatusType&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;StatusType&quot;
                    value={StatusType}
                    onChange={(e) =&gt; {
                      setStatusType(e.target.value);
                    }}
                    name=&quot;StatusType&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;RegistrationDate&lt;/label&gt;
                  &lt;input
                    type=&quot;date&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;RegistrationDate&quot;
                    value={RegistrationDate}
                    onChange={(e) =&gt; {
                      setRegistrationDate(e.target.value);
                    }}
                    name=&quot;RegistrationDate&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;ClosingDate&lt;/label&gt;
                  &lt;input
                    type=&quot;date&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;ClosingDate&quot;
                    value={ClosingDate}
                    onChange={(e) =&gt; {
                      setClosingDate(e.target.value);
                    }}
                    name=&quot;ClosingDate&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;RegisteredBy&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;RegisteredBy&quot;
                    value={RegisteredBy}
                    onChange={(e) =&gt; {
                      setRegisteredBy(e.target.value);
                    }}
                    name=&quot;RegisteredBy&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;ClosedBy&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;ClosedBy&quot;
                    value={ClosedBy}
                    onChange={(e) =&gt; {
                      setClosedBy(e.target.value);
                    }}
                    name=&quot;ClosedBy&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;CustomerAttachmentLinks&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;CustomerAttachmentLinks&quot;
                    value={CustomerAttachmentLinks}
                    onChange={(e) =&gt; {
                      setCustomerAttachmentLinks(e.target.value);
                    }}
                    name=&quot;CustomerAttachmentLinks&quot;
                  /&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div className=&quot;form-class8&quot;&gt;
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;VendorAttachmentLinks&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;VendorAttachmentLinks&quot;
                    value={VendorAttachmentLinks}
                    onChange={(e) =&gt; {
                      setVendorAttachmentLinks(e.target.value);
                    }}
                    name=&quot;VendorAttachmentLinks&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;RecordChanged&lt;/label&gt;
                  &lt;input
                    type=&quot;text&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;RecordChanged&quot;
                    value={RecordChanged}
                    onChange={(e) =&gt; {
                      setRecordChanged(e.target.value);
                    }}
                    name=&quot;RecordChanged&quot;
                  /&gt;
                &lt;/div&gt;
  
                &lt;div className=&quot;form-group&quot;&gt;
                  &lt;label&gt;DateEntered&lt;/label&gt;
                  &lt;input
                    type=&quot;date&quot;
                    className=&quot;form-control&quot;
                    placeholder=&quot;DateEntered&quot;
                    value={DateEntered}
                    onChange={(e) =&gt; {
                      setDateEntered(e.target.value);
                    }}
                    name=&quot;DateEntered&quot;
                  /&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;button className=&quot;btn btn-primary btn-block&quot;&gt;Edit&lt;/button&gt;
            &lt;/form&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    );
  }
  
  export default withRouter(TicketMaster_Edit);
  </code></pre>
  <p><strong>backend code from index.js:</strong></p>
  <pre><code>app.put(&quot;/upticketmst/:DocNo&quot;, (req, res) =&gt; {
    const DocuNo = req.params.DocNo;
    const CmpnyCode = req.body.CmpnyCode;
    const DocNo = req.body.DocNo;
    const DocDate = req.body.DocDate;
    const DocType = req.body.DocType;
    const AccCode = req.body.AccCode;
    const AccName = req.body.AccName;
    const OtherTradingName = req.body.OtherTradingName;
    const MobileNo = req.body.MobileNo;
    const Email = req.body.Email;
    const RequestType = req.body.RequestType;
    const Description = req.body.Description;
    const ServiceCover = req.body.ServiceCover;
    const ContractDetail = req.body.ContractDetail;
    const BillingDetail = req.body.BillingDetail;
    const OtherDetail = req.body.OtherDetail;
    const AssignedTo = req.body.AssignedTo;
    const VendorObservation = req.body.VendorObservation;
    const Conclusion = req.body.Conclusion;
    const StatusType = req.body.StatusType;
    const RegistrationDate = req.body.RegistrationDate;
    const ClosingDate = req.body.ClosingDate;
    const RegisteredBy = req.body.RegisteredBy;
    const ClosedBy = req.body.ClosedBy;
    const CustomerAttachmentLinks = req.body.CustomerAttachmentLinks;
    const VendorAttachmentLinks = req.body.VendorAttachmentLinks;
    const RecordChanged = req.body.RecordChanged;
    const DateEntered = req.body.DateEntered;
  
    db.query(
      &quot;UPDATE ticketmst SET CmpnyCode=?, DocNo=?, DocDate=?, DocType=?, AccCode=?, AccName=?, OtherTradingName=?, MobileNo=?, Email=?,RequestType=?, Description=?, SeviceCover=?, ContractDetail=?, BillingDetail=?, OtherDetail=?, AssignedTo=?, VendorObservation=?, Conclusion=?, StatusType=?, RegistrationDate=?, ClosingDate=?, RegisteredBy=?, ClosedBy=?, CustomerAttachmentLinks=?, VendorAttachmentLinks=?, RecordChanged=?, DateEntered=? WHERE DocNo=?&quot;,
      [
        CmpnyCode,
        DocNo,
        DocDate,
        DocType,
        AccCode,
        AccName,
        OtherTradingName,
        MobileNo,
        Email,
        RequestType,
        Description,
        ServiceCover,
        ContractDetail,
        BillingDetail,
        OtherDetail,
        AssignedTo,
        VendorObservation,
        Conclusion,
        StatusType,
        RegistrationDate,
        ClosingDate,
        RegisteredBy,
        ClosingDate,
        RegisteredBy,
        ClosedBy,
        CustomerAttachmentLinks,
        VendorAttachmentLinks,
        RecordChanged,
        DateEntered,
        DocuNo,
      ],
      (err, result) =&gt; {
        if (err) {
          console.log(err);
        } else {
          res.send(result);
        }
      }
    );
  });
  </code></pre>
  <p>Even if the mistake may be stupid or something please help me out as I have tried to see and scrutinized it hard but cannot figure out what I did wrong.</p>