Help with UPDATE IN MySQL

2

Hello friends, good evening, I have problems with my code and I can make it work, but I can not change the record in the database.

<?php require_once('Connections/clientes.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 suscriptor SET numero=%s, cliente=%s, paquete=%s, oportuno=%s, lista=%s, elector=%s, serie1=%s, serie2=%s, serie3=%s WHERE numero=%s",
                       GetSQLValueString($_POST['numero'], "text"),
                       GetSQLValueString($_POST['cliente'], "text"),
                       GetSQLValueString($_POST['paquete'], "text"),
                       GetSQLValueString($_POST['oportuno'], "text"),
                       GetSQLValueString($_POST['lista'], "text"),
                       GetSQLValueString($_POST['elector'], "text"),
                       GetSQLValueString($_POST['serie1'], "text"),
                       GetSQLValueString($_POST['serie2'], "text"),
                       GetSQLValueString($_POST['serie3'], "text"));

  mysql_select_db($database_clientes, $clientes);


  $updateGoTo = "guardado.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

mysql_select_db($database_clientes, $clientes);
$valor = $_GET['numero'];
$query_Recordset1 = "SELECT * FROM suscriptor WHERE numero=$valor";
$Recordset1 = mysql_query($query_Recordset1, $clientes) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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=iso-8859-1" />
<title>SGC - Sistema de gestion de clientes</title>
<style type="text/css">
body {margin:0;}
ul.topnav {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333;
}

ul.topnav li {float: left;}

ul.topnav li a {
  display: inline-block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  transition: 0.3s;
  font-size: 17px;
}

li a.active {
    background-color: #4CAF50;
    color: white;
}

li a:hover:not(.active) {
    background-color: #555;
    color: white;
}

ul.topnav li a:hover {background-color: #111;}

ul.topnav li.icon {display: none;}

@media screen and (max-width:680px) {
  ul.topnav li:not(:first-child) {display: none;}
  ul.topnav li.icon {
    float: right;
    display: inline-block;
  }
}

@media screen and (max-width:680px) {
  ul.topnav.responsive {position: relative;}
  ul.topnav.responsive li.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  ul.topnav.responsive li {
    float: none;
    display: inline;
  }
  ul.topnav.responsive li a {
    display: block;
    text-align: left;
  }
}
body,td,th {
    font-family: Verdana, Geneva, sans-serif;
    font-size: 12px;
    text-align: center;
}
</style>
</head>

<body>
<ul class="topnav">
  <li><a href="index.php">Inicio</a></li>
  <li><a href="nvocliente.php">Ingresar registro</a></li>
  <li><a href="consult.php">Buscar registro</a></li>
  <li><a class="active" href="econsult.php">Editar registro</a></li>
  <li><a href="dconsult.php">Eliminar registro</a></li>
  <li><a href="edtcliente.php">Global registros</a></li>
  <li class="icon">
    <a href="javascript:void(0);" onclick="myFunction()">&#9776;</a>
  </li>
</ul>
<script>
function myFunction() {
    document.getElementsByClassName("topnav")[0].classList.toggle("responsive");
}
</script>
<h1>Modificar registro (No sirve)</h1>
<br>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">numero:</td>
      <td><?php echo $row_Recordset1['numero']; ?></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">cliente:</td>
      <td><input type="text" name="cliente" value="<?php echo $row_Recordset1['cliente']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">paquete:</td>
      <td><input type="text" name="paquete" value="<?php echo $row_Recordset1['paquete']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">oportuno:</td>
      <td><input type="text" name="oportuno" value="<?php echo $row_Recordset1['oportuno']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">lista:</td>
      <td><input type="text" name="lista" value="<?php echo $row_Recordset1['lista']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">elector:</td>
      <td><input type="text" name="elector" value="<?php echo $row_Recordset1['elector']; ?>" size="32"></td>
      <tr valign="baseline">
      <td nowrap align="right">serie1:</td>
      <td><input type="text" name="serie1" value="<?php echo $row_Recordset1['serie1']; ?>" size="32"></td>
      <tr valign="baseline">
      <td nowrap align="right">serie2:</td>
      <td><input type="text" name="serie2" value="<?php echo $row_Recordset1['serie2']; ?>" size="32"></td>
      <tr valign="baseline">
      <td nowrap align="right">serie3:</td>
      <td><input type="text" name="serie3" value="<?php echo $row_Recordset1['serie3']; ?>" size="32"></td>
    </tr>
    </tr>
    </tr>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="Actualizar registro"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="numero" value="<?php echo $row_Recordset1['numero']; ?>">
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
    
asked by Cesar David Leon Ramirez 11.09.2018 в 06:29
source

0 answers