Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
Incorrect integer value '' for column... Mysql

I would like to allow null values to be submitted for this column but whenever it is left empty I get this notification. I checked my table and confirmed the column allows null values. I'm still new to sql and learning .

HTML

<div id="Temp">
                <label for="Temperature">Temperature</label>
                <input id="Temperature" type="number" name="Temperature">
            </div>
            <div id="Vol">
                <label for="Volume">Volume</label>
                <input id="Volume" type="number" name="Volume">
            </div>
            <input type="submit" value="OK" />

JS

app.post("/device-added", function (req, res) {
        let sqlquery = "INSERT INTO devices (Name, Type, Room, Power, Status, Temperature, Volume) VALUES (?,?,?,?,?,?,?)";
        let newrecord = [req.body.Name, req.body.Type, req.body.Room, req.body.Power, req.body.Status, req.body.Temperature, req.body.Volume];
        // execute sql query
        db.query(sqlquery, newrecord, (err, result) => {
            if (err) {
                return console.error(err.message);
            }
        });
        res.render("device-added.html");
    });
}

enter image description here

If I insert a number in temperature it will give me the error for volume and vice versa

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Can you try this.

let newrecord = [req.body.Name, req.body.Type, req.body.Room, req.body.Power, req.body.Status, req.body.Temperature || null, req.body.Volume];

In your code temperature us being passed as an empty string( i.e ""), and thus you get this error as according to your table structure it will only allow integers or null

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!