Very good! It is the first time that I have this strange error that appears when trying to edit a record of the table called state in php format in conjunction with html in the database I still use PhpMyAdmin. I have been updating with the sql injections, to maintain the necessary security, I still use the Mysqli with procedural style.
Table status
-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 26-05-2017 a las 16:19:22
-- Versión del servidor: 10.1.21-MariaDB
-- Versión de PHP: 5.6.30
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de datos: 'webpractica'
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla 'estado'
--
CREATE TABLE 'estado' (
'id_estado' int(11) NOT NULL,
'Estado' varchar(100) DEFAULT NULL,
'Fecha_Creacion' date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla 'estado'
--
INSERT INTO 'estado' ('id_estado', 'Estado', 'Fecha_Creacion') VALUES
(1, 'Completado', '2017-05-13'),
(2, 'Incompleto', '2017-05-13'),
(3, 'Analizado', '2017-05-13'),
(4, 'Bloqueado', '2017-05-13'),
(7, 'Inedit', '2017-05-26');
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla 'estado'
--
ALTER TABLE 'estado'
ADD PRIMARY KEY ('id_estado');
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla 'estado'
--
ALTER TABLE 'estado'
MODIFY 'id_estado' int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Edit.html
<form method="POST" action="editar.php">
id_estado: <input type= "text" name="id_estado"><br>
Estado: <input type="text" name= "estado"><br>
Fecha_Creacion: <input type="text" name="fecha" value="<?php date_default_timezone_set('Europe/Madrid'); echo date('Y-m-d'); ?>"><br>
<input type="submit" name="editar" value="Editar informacion">
</form>
edit.php
<?php
$msg = $id_estado = $estado = $fecha_actual = NULL;
if(isset($_POST['editar'])) {
$id_estado = $_POST['id_estado'];
$estado = $_POST['estado'];
$fecha_actual = $_POST['fecha'];
if ($id_estado && $estado && $fecha_actual) {
$link = mysqli_connect("localhost", "root", "localhost", "webpractica");
if (mysqli_connect_errno()) {
printf("Falló la conexión: %s\n", mysqli_connect_error());
exit();
}
$query = mysqli_query($link, "UPDATE estado SET id_estado='$id_estado', Estado='$estado', Fecha_Creacion='$fecha_actual'");
if(!$query) {
printf("Error: %s\n", mysqli_error($link));
} else {
$msg = "Los datos se editaron correctamente";
}
}
}
echo $msg;
?>
When trying to set edit the record of a table, let's say the id 7 that is seen in the database (the state table), which would be 7, inedit, 2017-05-26 and after doing submit, it appears this error:
What makes me wonder, I do not know if I did well for the mysqli query to edit.php following the format of mysqli procedural style, I think the error must be there or in the state table? I researched about it and there was no answer about it. I await your response! Many greetings!