Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7048899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:56:50+00:00 2026-05-28T02:56:50+00:00

I have a script that seems to not work, it it meant to update

  • 0

I have a script that seems to not work, it it meant to update an SQL database. The code looks fine, but it seems to me that when I submit the ID in where the data is meant to be entered into doesn’t work.

I can’t seem to find the cause. Can anyone here help me?

The script is below.

When I use the error check code, the only thing I get out of it is this:

Query is : UPDATE ncmr SET ab = ‘Matt Ridge’, date = ‘2012-01-09’,
part = ‘K17212191′, rev = ’01’ , partdesc = ” , ncmrqty = ‘2’ , comp
= ‘Nexx Systems Inc.’ , ncmrid = ‘1243’ , rma = ‘Empty’ , jno = ‘Empty’ , fdt = ‘none’ , cof = ‘none’ , fab1 = ‘Andy Kahl’ , fab2 =
‘–None–‘ , fab3 = ‘–None–‘ , non = ” , dis = ” , comm = ” ,
caad = ” , po = ‘Empty’ , pod = ‘1969-12-31’ , dri = ‘1969-12-31’
WHERE id = ”

There are no errors, but I notice that the ID is not showing upon posting. Is there a reason why this is happening?

I will post a link if required.

<?php
require_once('connectvars.php');
echo '<div id="postwrap">'
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>PDI NCMR - Edit</title>
  <link rel="stylesheet" type="text/css" href="CSS/postie.css" />
</head>
<body>
   <div id="logo">
    <img src="../images/PDI_Logo_2.1.gif" alt="PDI Logo" />
</div>

<?php
  if (isset($_POST['submit'])) {
// Connect to the database
    $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

// Enter data into the database
    $ab = mysqli_real_escape_string($dbc, trim($_POST['ab']));
    $date = mysqli_real_escape_string($dbc, trim(date('Y-m-d',strtotime ($_POST['date']))));
    $part = mysqli_real_escape_string($dbc, trim($_POST['part']));
    $rev = mysqli_real_escape_string($dbc, trim($_POST['rev']));
    $partdesc = mysqli_real_escape_string($dbc, trim($_POST['partdesc']));
    $ncmrqty = mysqli_real_escape_string($dbc, trim($_POST['ncmrqty']));
    $comp = mysqli_real_escape_string($dbc, trim($_POST['comp']));
    $ncmrid = mysqli_real_escape_string($dbc, trim($_POST['ncmrid']));
    $rma = mysqli_real_escape_string($dbc, trim($_POST['rma']));
    $jno = mysqli_real_escape_string($dbc, trim($_POST['jno']));
    $fdt = mysqli_real_escape_string($dbc, trim($_POST['fdt']));
    $cof = mysqli_real_escape_string($dbc, trim($_POST['cof']));
    $fab1= mysqli_real_escape_string($dbc, trim($_POST['fab1']));
    $fab2= mysqli_real_escape_string($dbc, trim($_POST['fab2']));
    $fab3= mysqli_real_escape_string($dbc, trim($_POST['fab3']));
    $non= mysqli_real_escape_string($dbc, trim($_POST['non']));
    $dis= mysqli_real_escape_string($dbc, trim($_POST['dis']));
    $comm= mysqli_real_escape_string($dbc, trim($_POST['comm']));
    $caad= mysqli_real_escape_string($dbc, trim($_POST['caad']));
    $po= mysqli_real_escape_string($dbc, trim($_POST['po']));
    $pod = mysqli_real_escape_string($dbc, trim(date('Y-m-d',strtotime($_POST['pod']))));
    $dri = mysqli_real_escape_string($dbc, trim(date('Y-m-d',strtotime($_POST['dri']))));

    $query = "UPDATE ncmr SET ab = '$ab', date = '$date', part = '$part', rev = '$rev' , partdesc = '$partdesc' , ncmrqty = '$ncmrqty' , comp = '$comp' , ncmrid = '$ncmrid' , rma = '$rma' , jno = '$jno' , fdt = '$fdt' , cof = '$cof' , fab1 = '$fab1' , fab2 = '$fab2' , fab3 = '$fab3' , non = '$non' , dis = '$dis' , comm = '$comm' , caad = '$caad' , po = '$po' , pod = '$pod' , dri = '$dri'  WHERE id = '" . $_GET['id'] . "'";

 // echo your raw query and look for obvious errors
     echo "Query is : " . $query . "<br />";

      // and at least use a basic mechanism to trap possibles errors
       mysqli_query($dbc, $query)  or die('Query Error : ' . mysqli_error($dbc));

            // Clear the form data
    $ab = "";
    $date = "";
    $part = "";
    $rev = "";
    $partdesc = "";
    $ncmrqty = "";
    $comp = "";
    $ncmrid = "";
    $rma = "";
    $jno = "";
    $fdt = "";
    $cof = "";
    $fab1= "";
    $fab2= "";
    $fab3= "";
    $non= "";
    $dis= "";
    $comm= "";
    $caad= "";
    $po= "";
    $pod = "";
    $dri = "";

// Confirm success with the user
        echo '<p>If you wish to edit more NCMRs, please <a href="list.php">go to the admin page!</a></p>';

            mysqli_close($dbc);
            }

  else {    

// Connect to the database
  $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
// Grab the profile data from the database
  if (!isset($_GET['id'])) {
    $query = "SELECT * FROM ncmr WHERE id = '$id'";
  }
  else {
    $query = "SELECT * FROM ncmr WHERE id = '" . $_GET['id'] . "'";
  }
  $data = mysqli_query($dbc, $query);

  if (mysqli_num_rows($data) == 1) { 
// The user row was found so display the user data
    $row = mysqli_fetch_array($data);
    echo'<div id="title"><h3 id="NCMR2">Non-Conforming Materials Report (NCMR:&nbsp;&nbsp;' . $row['rma'] . ')</h3></div>';
echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>";
    echo '<fieldset>';

        echo '<div id="box1">';
            if (empty($row['ab'])) $row['ab'] = "Empty";
            if (empty($row['date'])) $row['date'] = "Empty";
            if (empty($row['part'])) $row['part'] = "Empty";
            if (empty($row['rev'])) $row['rev'] = "Empty";
            if (empty($row['partdesc'])) $row['partdesc'] = "Empty";
            if (empty($row['ncmrqty'])) $row['ncmrqty'] = "Empty";
            echo '<div id="ab"><span class="b">Added By:&nbsp;&nbsp;</span><input type="text" name="ab" value="' . $row['ab'] . '" /></div>';
            echo '<div id="date"><span class="b">Date Filed:&nbsp;&nbsp;</span><input type="text" name="date" value="' . $row['date'] . '" /></div>';
            echo '<div id="part"><span class="b">Part Number:&nbsp;&nbsp;</span><input type="text" name="part" value="' . $row['part'] . '" /></div>';
            echo '<div id="rev"><span class="b">Part Revision:&nbsp;&nbsp;</span><input type="text" name="rev" value="' . $row['rev'] . '" /></div>';
            echo '<div id="partdesc"><span class="b">Part Description:&nbsp;&nbsp;</span><textarea rows="4" cols="22">' . $row['partdesc'] . '</textarea></div>';
            echo '<div id="ncmrqty"><span class="b">NCMR Qty:&nbsp;&nbsp;</span><input type="text" name="ncmrqty" value="' . $row['ncmrqty'] . '" /></div>';
        echo '</div>';

//Company, Customer NCMR, Internal RMA, and Job Number
        echo '<div id="box2">';
            if (empty($row['comp'])) $row['comp'] = "Empty";
            if (empty($row['ncmrid'])) $row['ncmrid'] = "Empty";
            if (empty($row['rma'])) $row['rma'] = "Empty";
            if (empty($row['jno'])) $row['jno'] = "Empty";
                echo '<div id="comp"><span class="b">Company:&nbsp;&nbsp;</span><input type="text" name="comp" value="' . $row['comp'] . '" /></div>';
                    echo '<div id="ncmrid"><span class="b">Customer NCMR ID:&nbsp;&nbsp;</span><input type="text" name="ncmrid" value="' . $row['ncmrid'] . '" /></div>';
                    echo '<div id="rma"><span class="b">Internal RMA #:&nbsp;&nbsp;</span><input type="text" name="rma" value="' . $row['rma'] . '" /></div>';
                    echo '<div id="jno"><span class="b">Job #:&nbsp;&nbsp;</span><input type="text" name="jno" value="' . $row['jno'] . '" /></div>';
        echo '</div>';

//Type of Failure and Class of Failure
        echo '<div id="box3">';
            echo '<h2>Failure</h2>';
                echo '<div id="cof"><span class="b">Class of Failure:&nbsp;&nbsp;</span><input type="text" name="cof"  size="15" value="' . $row['cof'] . '" /></div>';
                echo '<div id="fdt"><span class="b">Failure Due To:&nbsp;&nbsp;</span><input type="text" name="fdt"  size="15" value="' . $row['fdt'] . '" /></div>';

            echo '</div>';

//Fabricators
        echo '<div id="box4">';
            echo '<h2>Fabricators</h2>';
if ($row['fab1']="--None--")
{
    echo'<div id="fab1">';
    $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 
    $mysqli->select_db('user');
    $result = $mysqli->query("SELECT * FROM user"); 
    echo "<SELECT name='fab1'>\n";
    while($row = $result->fetch_assoc())
    {
        echo "<option value='{$row['user']}'>{$row['user']}</option>\n";
    }
    echo "</select>\n";
    echo '</div>';
}
else
{
    echo'<div id="fab1">';
    $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 
    $mysqli->select_db('user');
    $result = $mysqli->query("SELECT * FROM user"); 
    echo "<SELECT name='fab1'>\n";
    while($row = $result->fetch_assoc())
    {
        echo "<option value='{$row['user']}'>{$row['user']}</option>\n";
    }
    echo "</select>\n";
    echo '</div>';
}


if ($row['fab2']="--None--")
{
    echo'<div id="fab2">';
    $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 
    $mysqli->select_db('user');
    $result = $mysqli->query("SELECT * FROM user"); 
    echo "<SELECT name='fab2'>\n";
    while($row = $result->fetch_assoc())
    {
        echo "<option value='{$row['user']}'>{$row['user']}</option>\n";
    }
    echo "</select>\n";
    echo '</div>';
}
else
{
    echo '<div id="fab2"><span class="b"></span><input type="text" name="fab1"  size="20" value="' . $row['fab1'] . '" /></div>';
    echo '</div>';
}
if ($row['fab3']="--None--")
{
    echo'<div id="fab3">';
    $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 
    $mysqli->select_db('user');
    $result = $mysqli->query("SELECT * FROM user"); 
    echo "<SELECT name='fab3'>\n";
    while($row = $result->fetch_assoc())
    {
        echo "<option value='{$row['user']}'>{$row['user']}</option>\n";
    }
    echo "</select>\n";
    echo '</div>';
}
else
{
    echo '<div id="fab3"><span class="b"></span><input type="text" name="fab1"  size="20" value="' . $row['fab1'] . '" /></div>';
    echo '</div>';
}       echo '</div>';

//Nonconformity, Disposition, Comments and Comments & Additional Details
        echo '<div id="box5">';
            if (empty($row['non'])) $row['non'] = "Empty";
            if (empty($row['dis'])) $row['dis'] = "Empty";
            if (empty($row['comm'])) $row['comm'] = "Empty";
            if (empty($row['caad'])) $row['caad'] = "Empty";

            echo '<div id="non"><span class="b">Nonconformity:&nbsp;&nbsp;</span><textarea rows="4" cols="105">' . $row['non'] . '</textarea></div>';
            echo '<div id="dis"><span class="b">Disposition:&nbsp;&nbsp;</span><textarea rows="4" cols="105">' . $row['dis'] . '</textarea></div>';
            echo '<div id="comm"><span class="b">Comments:&nbsp;&nbsp;</span><textarea rows="4" cols="105">' . $row['comm'] . '</textarea></div>';
            echo '<div id="caad"><span class="b">Comments and/or Additional Details:&nbsp;&nbsp;</span><textarea rows="4" cols="105">' . $row['caad'] . '</textarea></div>';

                echo '<div id="podr">';
                        if (empty($row['po'])) $row['po'] ="Empty";
                        if (empty($row['pod'])) $row['pod'] ="Empty";
                        if (empty($row['dir'])) $row['dri'] ="Empty";

                    echo '<div id="po"><span class="b">PO:&nbsp;&nbsp;</span><input type="text" name="po"  size="7" value="' . $row['po'] . '" /></div>';
                    echo '<div id="pod"><span class="b">PO Date:&nbsp;&nbsp;</span><input type="text" name="pod"  size="7" value="' . $row['pod'] . '" /></div>';
                    echo '<div id="dri"><span class="b">Date Received:&nbsp;&nbsp;</span><input type="text" name="dri"  size="7" value="' . $row['dri'] . '" /></div>';
                echo '</div>';
            echo '<div id="button2"><input type="submit" value="Submit Edits" name="submit" /></div>';
        echo '</div>';
    echo '</fieldset>';
echo '</form>';
        }
    }

echo '</div>';

?>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:56:51+00:00Added an answer on May 28, 2026 at 2:56 am

    You are using $_GET to retrieve the id but $_POST for everything else. Try changing it to $_POST…and there will be a host of warnings from everyone on SO about why this is dangerous. Look up SQL injection on google.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that works fine on my test server (using IIS6). The
I'm using mongoose in a script that is not meant to run continuously, and
I have two web pages which work basically the same, code-wise, but one of
I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example),
I have a script that retrieves objects from a remote server through an Ajax
I have a script that checks responses from HTTP servers using the PEAR HTTP
I have a script that takes a table name and generates a control file
I have a script that renders graphs in gnuplot. The graphs all end up
I have a script that successfully encrypts a credit card. I need it to
I have an script that receives an encrypted url and from that generates a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.