Help with the update in mysql

0

I have a code in php and mysql to edit a ticket but when I edit it with the new values it tells me the message as if it had been inserted but it does not enter the database

the ajax code to edit

<?php
include('is_logged.php');
if (empty($_POST['mod_incidencia'])) {
       $errors[] = "incidencia vacío";
    }else if (empty($_POST['mod_detalle'])) {
       $errors[] = "detalle vacío";
    }else if (empty($_POST['mod_tema'])) {
       $errors[] = "tema vacío";
    }  else if (


    !empty($_POST['mod_tema']) &&
    !empty($_POST['mod_detalle']) &&
        !empty($_POST['mod_incidencia'])
    ){

    require_once ("../config/db.php");
    require_once ("../config/conexion.php");
    $incidencia=mysqli_real_escape_string($con,(strip_tags($_POST["mod_incidencia"],ENT_QUOTES)));
    $tema=mysqli_real_escape_string($con,(strip_tags($_POST["mod_tema"],ENT_QUOTES)));
    $detalle=mysqli_real_escape_string($con,(strip_tags($_POST["mod_detalle"],ENT_QUOTES)));


    $Nticket=intval($_POST['mod_Nticket']);
    $sql="UPDATE ticket SET incidencia='".$incidencia."',  tema='".$tema."',
    detalle='".$detalle."' WHERE Nticket='".$Nticket."'";
    $query_update = mysqli_query($con,$sql);
        if ($query_update){
            $messages[] = "Ticket ha sido actualizado satisfactoriamente.";

           //me aparece este mensaje cuando ingreso pero no se actualiza en la BD\

                   } else{
            $errors []= "Lo siento algo ha salido mal intenta nuevamente.".mysqli_error($con);
        }
    } else {
        $errors []= "Error desconocido.";
    }

    if (isset($errors)){

        ?>
        <div class="alert alert-danger" role="alert">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
                <strong>Error!</strong> 
                <?php
                    foreach ($errors as $error) {
                            echo $error;
                        }
                    ?>
        </div>
        <?php
        }
        if (isset($messages)){

            ?>
            <div class="alert alert-success" role="alert">
                    <button type="button" class="close" data-dismiss="alert">&times;</button>
                    <strong>¡Bien hecho!</strong>
                    <?php
                        foreach ($messages as $message) {
                                echo $message;
                            }
                        ?>
            </div>
            <?php
        }
?>
    
asked by Kevin Salazar 04.10.2017 в 17:13
source

1 answer

1

Try printing before your request the variable $Nticket to verify that it is evidently bringing the right information, otherwise you should check in your js the moment in which you capture and send those variables since the problem It could come from there.

As a tip so that debuggees correctly: print the variable in each of the steps you use to reach the update , that is, remove console.log() in your js and for a last echo in your php so you can verify that from front to back the variable arrives correctly, so you can see at what moment your code is broken.

I hope you serve, greetings!

    
answered by 04.10.2017 / 21:51
source