DEV Community

loading...

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

zeeshanmehdi profile image zeeshan mehdi Updated on ・1 min read


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);
        }
    });

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);
        }
    });

Discussion (0)

Forem Open with the Forem app