I have a problem with MYSQL and LINUX when altering a value

0

I have this code to update an item for example if the amount is at 8 and I add 2, when updating the page the change is saved but I do not know why the error is coming out. alert ('Something went wrong, please try again');

before I had the service in windows and it works fine when I pass it to linux the error came out

This I do for in the update

public function update_item_qty($type, $id, $fromqty, $qty) {
    $to = $fromqty + $qty;

    if(!is_numeric($id) || !is_numeric($fromqty) || !is_numeric($qty))
        die('inc/items_core.php - update_item_qty - Non Numeric Values');

    // Primero actualiza el item
    if($type == 1) {
        $prepared = $this->prepare("UPDATE invento_items SET qty = qty+$qty WHERE id=?", 'update_item_qty()');
        $this->bind_param($prepared->bind_param('i', $id), 'update_item_qty()');
        $this->execute($prepared, 'update_item_qty()');
    }elseif($type == 2){
        $prepared = $this->prepare("UPDATE invento_items SET qty = qty-$qty WHERE id=?", 'update_item_qty()');
        $this->bind_param($prepared->bind_param('i', $id), 'update_item_qty()');
        $this->execute($prepared, 'update_item_qty()');
    }

PHP

// Actualiza la cantidad de items (Salidas/Entradas)
if($_POST['act'] == '3' || $_POST['act'] == '4') {
    if(!isset($_POST['id']) || !isset($_POST['val']) || !isset($_POST['fromval']) || $_POST['id'] == '' || $_POST['val'] == '' || $_POST['fromval'] == '')
        die('wrong');
    if($_POST['act'] == '3')
        $type = 1;
    elseif($_POST['act'] == '4') {
        $type = 2;
        $qty = $_items->get_item($_POST['id']);
        $qty = $qty->qty;
        if($qty < $_POST['val'])
            die('2');
    }

    if($_items->update_item_qty($type, $_POST['id'], $_POST['fromval'], $_POST['val']) == true)
        die('1');
    die('wrong');

JS

$.post('items.php', {
        'act':act,
        'id':id,
        'fromval':prev_value,
        'val':val
    }, function(data) {
        if(data == '2') {
            alert('No puedes ver más de '+prev_value+' referencias');
            return false;
        }else if(data == '1'){
            t.parent().parent().fadeOut(300, function() { this.remove(); });
            t.parent().parent().prev().children('td:nth-child(5)').fadeOut(200, function() {
                if(act == 3)
                    t.parent().parent().prev().children('td:nth-child(5)').html(parseInt(prev_value)+parseInt(val)).fadeIn(400);
                else if(act == 4)
                    t.parent().parent().prev().children('td:nth-child(5)').html(parseInt(prev_value)-parseInt(val)).fadeIn(400);
            });
        }else{
            alert('10 Algo salió mal. Por favor, inténtelo de nuevo');
        }
    });
    
asked by Saul Salazar 31.08.2018 в 22:26
source

1 answer

0

Fix it by changing the alert where it says

  

alert ('10 Something went wrong, please try again ');

for

  

location.reload ();

$.post('items.php', {
        'act':act,
        'id':id,
        'fromval':prev_value,
        'val':val
    }, function(data) {
        if(data == '2') {
            alert('No puedes ver más de '+prev_value+' referencias');
            return false;
        }else if(data == '1'){
            t.parent().parent().fadeOut(300, function() { this.remove(); });
            t.parent().parent().prev().children('td:nth-child(5)').fadeOut(200, function() {
                if(act == 3)
                    t.parent().parent().prev().children('td:nth-child(5)').html(parseInt(prev_value)+parseInt(val)).fadeIn(400);
                else if(act == 4)
                    t.parent().parent().prev().children('td:nth-child(5)').html(parseInt(prev_value)-parseInt(val)).fadeIn(400);
            });
        }else{
            alert('10 Algo salió mal. Por favor, inténtelo de nuevo');
        }
    });
    
answered by 31.08.2018 / 23:26
source