DEV Community

zeeshan mehdi
zeeshan mehdi

Posted on • Updated on

NOdejs MYSql Error: ER_TRUNCATED_WRONG_VALUE: Truncated incorrect DOUBLE value: 'admin1234'


Code causing issue

let query = `update users set email = ? and password = ? where id = ?`;
    console.log(query);
    connection.query(query,[id,email,pass], function(error, result, fields) {

        if (error) {
            console.log(`error ${error}`);
            callback(false);
        }else {
            console.log(result);
            if(result.affectedRows>0)
                callback(true);
            else
                callback(false);
        }
    });

Enter fullscreen mode Exit fullscreen mode

solution : Just replace AND with comma

let query = `update users set email = ?,password = ? where id = ?`;
    console.log(query);
    connection.query(query,[id,email,pass], function(error, result, fields) {

        if (error) {
            console.log(`error ${error}`);
            callback(false);
        }else {
            console.log(result);
            if(result.affectedRows>0)
                callback(true);
            else
                callback(false);
        }
    });
Enter fullscreen mode Exit fullscreen mode

Top comments (0)