MySQL problem | Help

Good evening! I’m working on my project and I can’t understand. why the line from MySQL does not want to be displayed.

connection.query(`SELECT * FROM MonitorCore WHERE value`, (rows) => {

Please, help me :slight_smile:

What errors are you getting in the logs?

Cannot read property 0 of undefined

Do you have rows defined?


@RiversideRocks, can help me?

Cannot read property 0 of undefined simply means is that you are trying to access the property 0 of an undefined variable. You most likely have rows variable undefined. Make sure that you have that variable properly set in your table, personally I would recommend you to print out stuff until you get some clues of where the problem may be in. Correct me if I am wrong.

this looks like it could end the connection before the query finishes

Thanks for the answers, but I just don’t quite understand why this error comes out, there was a code that returned undefined.

This code:

connection.query(`SELECT * FROM 'MonitorCore' WHERE value = '?'`, (rows) => {`${rows[0]}`);

Bot responce: undefined

btw, is this code simplified? you should be passing a value for the db to substitute in for the ?

undefined could be consistent with my guess above. if you’re really closing the connection before the query gets processed, maybe it’s the db’s behavior to pass rows = [] to that callback