为什么我的更新页面不工作


why is my update page not working?

当我点击提交按钮时,我的更新页面没有编辑数据库中的数据。我不知道我哪里出错了。我检查了与数据库的连接,它的工作很好,因为它正在检索以前的数据。

这是我的代码更新页面

<?php require_once('Connections/smpiconnection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_computer = 10;
$pageNum_computer = 0;
if (isset($_GET['pageNum_computer'])) {
  $pageNum_computer = $_GET['pageNum_computer'];
}
$startRow_computer = $pageNum_computer * $maxRows_computer;
mysql_select_db($database_smpiconnection, $smpiconnection);
$query_computer = "SELECT * FROM maklumat_pc";
$query_limit_computer = sprintf("%s LIMIT %d, %d", $query_computer, $startRow_computer, $maxRows_computer);
$computer = mysql_query($query_limit_computer, $smpiconnection) or die(mysql_error());
$row_computer = mysql_fetch_assoc($computer);
if (isset($_GET['totalRows_computer'])) {
  $totalRows_computer = $_GET['totalRows_computer'];
} else {
  $all_computer = mysql_query($query_computer);
  $totalRows_computer = mysql_num_rows($all_computer);
}
$totalPages_computer = ceil($totalRows_computer/$maxRows_computer)-1;
$queryString_computer = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_computer") == false && 
        stristr($param, "totalRows_computer") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_computer = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_computer = sprintf("&totalRows_computer=%d%s", $totalRows_computer, $queryString_computer);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.kl {
    font-weight: bold;
}
body {
    background-image: url(wooden.jpg);
}
</style>
</head>
<body>
<center>
<p><img src="bannercrop.png" alt="crop" width="1180" height="324" align="middle" longdesc="bannercrop.png" /></p>
<table border="1" cellpadding="1" cellspacing="1">
  <tr bgcolor="#33CCCC" class="kl">
    <td>Agensi</td>
    <td>Jabatan</td>
    <td>Work_Group</td>
    <td>Computer_Name</td>
    <td>Kategori_Infra</td>
    <td>Nama_Pengguna</td>
    <td>Jawatan</td>
    <td>Gred_Jawatan</td>
    <td>Kumpulan_Perubatan</td>
    <td>Tahun_Perolehan</td>
    <td>No_Siri_Komputer</td>
    <td>No_Aset</td>
    <td>Jenis_OS</td>
    <td>Jenama_PC</td>
    <td>Model_PC</td>
    <td>Model_Monitor</td>
    <td>Harga_Infra</td>
    <td>Cara_Perolehan</td>
    <td>Status_Antivirus</td>
    <td>Lesen_Antivirus</td>
    <td>Jenama_Antivirus</td>
    <td>Status_Penyelenggaraan</td>
    <td>Syarikat_Penyelenggaraan</td>
    <td>Status_Lan_Pc</td>
    <td>Ip_address</td>
    <td>Status_Infra</td>
    <td>Processor</td>
    <td>Ram</td>
    <td>Hard_Disk</td>
    <td>&nbsp;</td>
  </tr>
  <?php do { ?>
    <tr bgcolor="#FFFF99">
      <td><?php echo $row_computer['Agensi']; ?></td>
      <td><?php echo $row_computer['Jabatan']; ?></td>
      <td><?php echo $row_computer['Work_Group']; ?></td>
      <td><?php echo $row_computer['Computer_Name']; ?></td>
      <td><?php echo $row_computer['Kategori_Infra']; ?></td>
      <td><?php echo $row_computer['Nama_Pengguna']; ?></td>
      <td><?php echo $row_computer['Jawatan']; ?></td>
      <td><?php echo $row_computer['Gred_Jawatan']; ?></td>
      <td><?php echo $row_computer['Kumpulan_Perubatan']; ?></td>
      <td><?php echo $row_computer['Tahun_Perolehan']; ?></td>
      <td><?php echo $row_computer['No_Siri_Komputer']; ?></td>
      <td><?php echo $row_computer['No_Aset']; ?></td>
      <td><?php echo $row_computer['Jenis_OS']; ?></td>
      <td><?php echo $row_computer['Jenama_PC']; ?></td>
      <td><?php echo $row_computer['Model_PC']; ?></td>
      <td><?php echo $row_computer['Model_Monitor']; ?></td>
      <td><?php echo $row_computer['Harga_Infra']; ?></td>
      <td><?php echo $row_computer['Cara_Perolehan']; ?></td>
      <td><?php echo $row_computer['Status_Antivirus']; ?></td>
      <td><?php echo $row_computer['Lesen_Antivirus']; ?></td>
      <td><?php echo $row_computer['Jenama_Antivirus']; ?></td>
      <td><?php echo $row_computer['Status_Penyelenggaraan']; ?></td>
      <td><?php echo $row_computer['Syarikat_Penyelenggaraan']; ?></td>
      <td><?php echo $row_computer['Status_Lan_Pc']; ?></td>
      <td><?php echo $row_computer['Ip_address']; ?></td>
      <td><?php echo $row_computer['Status_Infra']; ?></td>
      <td><?php echo $row_computer['Processor']; ?></td>
      <td><?php echo $row_computer['Ram']; ?></td>
      <td><?php echo $row_computer['Hard_Disk']; ?></td>
      <td><a href="updateprinter.php">update</a></td>
    </tr>
    <?php } while ($row_computer = mysql_fetch_assoc($computer)); ?>
</table>
<a href="<?php printf("%s?pageNum_computer=%d%s", $currentPage, max(0, $pageNum_computer - 1), $queryString_computer); ?>">Previous</a>
</center>
</body>
</html>
<?php
mysql_free_result($computer);
?>

这是我的编辑代码。上一页应该链接到本页

<?php
  $mysqlconnection= mysql_connect ("localhost", "root","")  or die (mysql_error());  
    mysql_select_db ("smpi");
	?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE maklumat_pencetak SET Jabatan=%s, Work_Group=%s, Kategori_Infra=%s, Nama_Pengguna=%s, Jawatan=%s, Gred_Jawatan=%s, Tahun_Perolehan=%s, No_Aset=%s, No_Siri=%s, Jenis_OS_Pc=%s, Jenama=%s, Model=%s, Harga_Infra=%s, Kategori_Printer=%s, Jenis_Printer=%s, Status_Infra=%s, Status_Penyelenggaran=%s, Syarikat_Penyelenggaran=%s WHERE Agensi=%s",
                       GetSQLValueString($_POST['Jabatan'], "text"),
                       GetSQLValueString($_POST['Work_Group'], "text"),
                       GetSQLValueString($_POST['Kategori_Infra'], "text"),
                       GetSQLValueString($_POST['Nama_Pengguna'], "text"),
                       GetSQLValueString($_POST['Jawatan'], "text"),
                       GetSQLValueString($_POST['Gred_Jawatan'], "text"),
                       GetSQLValueString($_POST['Tahun_Perolehan'], "int"),
                       GetSQLValueString($_POST['No_Aset'], "text"),
                       GetSQLValueString($_POST['No_Siri'], "text"),
                       GetSQLValueString($_POST['Jenis_OS_PC'], "text"),
                       GetSQLValueString($_POST['Jenama'], "text"),
                       GetSQLValueString($_POST['Model'], "text"),
                       GetSQLValueString($_POST['Harga_Infra'], "int"),
                       GetSQLValueString($_POST['Kategori_Printer'], "text"),
                       GetSQLValueString($_POST['Jenis_Printer'], "text"),
                       GetSQLValueString($_POST['Status_Infra'], "text"),
                       GetSQLValueString($_POST['Status_Penyelenggaran'], "text"),
                       GetSQLValueString($_POST['Syarikat_Penyelenggaran'], "text"),
                       GetSQLValueString($_POST['No_Siri'], "text"));
  mysql_select_db($database_smpiconnection, $smpiconnection);
  $Result1 = mysql_query($updateSQL, $smpiconnection) or die(mysql_error());
  $updateGoTo = "printerupdatepage.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db( "smpi");
$query_printer = "SELECT ALL FROM maklumat_pencetak";
$printer = mysql_query($query_printer, $mysqlconnection) or die(mysql_error());
$row_printer = mysql_fetch_assoc($printer);
$totalRows_printer = mysql_num_rows($printer);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
	background-image: url(wooden.jpg);
}
body,td,th {
	color: #FFF;
}
</style>
</head>
<body>
<center>
<p><img src="bannercrop.png" alt="crop" width="1180" height="324" align="middle" longdesc="bannercrop.png" /></p>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
  <p>
    <label for="Agensi">Agen<?php echo $row_printer['Agensi']; ?>si</label>
    :
    <input name="Agensi" type="text" id="Agensi" value="<?php echo $row_printer['Agensi']; ?>" />
  </p>
  <p>
    <label for="Jabatan">Jabat<?php echo $row_printer['Jabatan']; ?>an</label>
    :
    <input name="Jabatan" type="text" id="Jabatan" value="<?php echo $row_printer['Jabatan']; ?>" />
  </p>
  <p>
    <label for="Work_Group">Work Gr<?php echo $row_printer['Work_Group']; ?>oup</label>
    :
    <input name="Work_Group" type="text" id="Work_Group" value="<?php echo $row_printer['Work_Group']; ?>" />
  </p>
  <p>
    <label for="Kategori_Infra">Kategori Infra<?php echo $row_printer['Kategori_Infra']; ?>:</label>
    <input name="Kategori_Infra" type="text" id="Kategori_Infra" value="<?php echo $row_printer['Kategori_Infra']; ?>" />
  </p>
  <p>
    <label for="Nama_Pengguna">Nama_Pengguna<?php echo $row_printer['Nama_Pengguna']; ?>:</label>
    <input name="Nama_Pengguna" type="text" id="Nama_Pengguna" value="<?php echo $row_printer['Nama_Pengguna']; ?>" />
  </p>
  <p>
    <label for="Jawatan">Jawatan<?php echo $row_printer['Jawatan']; ?> :</label>
    <input name="Jawatan" type="text" id="Jawatan" value="<?php echo $row_printer['Jawatan']; ?>" />
  </p>
  <p>
    <label for="Gred_Jawatan">Gred Jawatan<?php echo $row_printer['Gred_Jawatan']; ?> :</label>
    <input name="Gred_Jawatan" type="text" id="Gred_Jawatan" value="<?php echo $row_printer['Gred_Jawatan']; ?>" />
  </p>
  <p>
    <label for="Tahun_Perolehan">Tahun Perolehan<?php echo $row_printer['Tahun_Perolehan']; ?>:</label>
    <input name="Tahun_Perolehan" type="text" id="Tahun_Perolehan" value="<?php echo $row_printer['Tahun_Perolehan']; ?>" />
  </p>
  <p>
    <label for="No_Aset">No Ase<?php echo $row_printer['No_Aset']; ?>t:</label>
    <input name="No_Aset" type="text" id="No_Aset" value="<?php echo $row_printer['No_Aset']; ?>" />
  </p>
  <p>
    <label for="No_Siri">No Siri<?php echo $row_printer['No_Siri']; ?>:</label>
    <input name="No_Siri" type="text" id="No_Siri" value="<?php echo $row_printer['No_Siri']; ?>" />
  </p>
  <p>
    <label for="Jenis_OS_PC">Jenis OS PC <?php echo $row_printer['Jenis_OS_Pc']; ?>:</label>
    <input name="Jenis_OS_PC" type="text" id="Jenis_OS_PC" value="<?php echo $row_printer['Jenis_OS_Pc']; ?>" />
  </p>
  <p>
    <label for="Jenama">Jenama<?php echo $row_printer['Jenama']; ?>:</label>
    <input name="Jenama" type="text" id="Jenama" value="<?php echo $row_printer['Jenama']; ?>" />
  </p>
  <p>
    <label for="Model">Model<?php echo $row_printer['Model']; ?> :</label>
    <input name="Model" type="text" id="Model" value="<?php echo $row_printer['Model']; ?>" />
  </p>
  <p>
    <label for="Harga_Infra">Harga Infra<?php echo $row_printer['Harga_Infra']; ?> :</label>
    <input name="Harga_Infra" type="text" id="Harga_Infra" value="<?php echo $row_printer['Harga_Infra']; ?>" />
  </p>
  <p>
    <label for="Kategori_Printer">Kategori Printer</label>
    <?php echo $row_printer['Kategori_Printer']; ?>
:    
<input name="Kategori_Printer" type="text" id="Kategori_Printer" value="<?php echo $row_printer['Kategori_Printer']; ?>" />
  </p>
  <p>
    <label for="Jenis_Printer">Jenis Printer <?php echo $row_printer['Jenis_Printer']; ?>:</label>
    <input name="Jenis_Printer" type="text" id="Jenis_Printer" value="<?php echo $row_printer['Jenis_Printer']; ?>" />
  </p>
  <p>
    <label for="Status_Infra">Status Infra <?php echo $row_printer['Status_Infra']; ?>:</label>
    <input name="Status_Infra" type="text" id="Status_Infra" value="<?php echo $row_printer['Status_Infra']; ?>" />
  </p>
  <p>
    <label for="Status_Penyelenggaran">Status Penyelenggaran<?php echo $row_printer['Status_Penyelenggaran']; ?>:</label>
    <input name="Status_Penyelenggaran" type="text" id="Status_Penyelenggaran" value="<?php echo $row_printer['Status_Penyelenggaran']; ?>" />
  </p>
  <p>
    <label for="Syarikat_Penyelenggaran">Syarikat Penyelenggaran<?php echo $row_printer['Syarikat_Penyelenggaran']; ?>:</label>
    <input name="Syarikat_Penyelenggaran" type="text" id="Syarikat_Penyelenggaran" value="<?php echo $row_printer['Syarikat_Penyelenggaran']; ?>" />
  </p>
  <p>
    <input type="submit" name="update" id="submit" value="UPDATE!" />
  </p>
  <input type="hidden" name="MM_update" value="form1" />
</form>
</center>
</body>
</html>
<?php
mysql_free_result($printer);
?>