the following ajax function sends the parameters correctly:
function concatenaredicion(idarchivoaeditar) {
var contenidoagregar = CKEDITOR.instances['editor1'].getData();
data = {
"texto":contenidoagregar,
"idinforme":idarchivoaeditar
}
$.ajax({
type: 'POST',
data: data,
url: 'php/editainforme.php',
success: function name(data) {
alert(data);
}
})
}
The problem is that file .php
executes the query but concatenates twice the same value
<?php
require_once('../conexion.php');
$texto = $_POST['texto'];
$informe = $_POST['idinforme'];
$stmt = mysqli_prepare($con, "UPDATE archivos_informes SET contenido = CONCAT(contenido,?)
WHERE idArchivo = ? ");
mysqli_stmt_bind_param($stmt, "si", $texto,$informe);
if (isset($_POST["texto"]) && !empty($_POST["texto"])) {
mysqli_stmt_execute($stmt);
if (!$stmt->execute()) {
echo "Falló la ejecución";
}else{
echo "Informe actualizado";
}
}else{
echo "Agruegue un contenido";
}
?>
The problem itself is as follows:
If in my variable $texto
has a value of <p>1</p>
in my database is concatenated twice as follows: <p>1</p><p>1</p>