Closed bogdy2016 closed 8 years ago
Hi! If you are getting that error from the code you posted, most likely it's because there is something in err
and so there are no returned rows.
You can see a very simple example of code in the README at https://github.com/felixge/node-mysql#introduction for what you should do, at minimum, with the err
argument. The standard callback pattern in Node.js means that if err
is set, all other arguments will be undefined
and you would have to act on that error in some way.
The most basic change you should make to your code above is to change it to the following:
if(offer.items_to_receive == undefined) return;
mysqlConnection.query('SELECT `value` FROM `info` WHERE `name`=\'maxitems\'', function(err, row, fields) {
if(err) throw err;
if(offer.items_to_receive.length > row[0].value) {
offers.declineOffer({tradeOfferId: offer.tradeofferid});
offer.items_to_receive = [];
mysqlConnection.query('INSERT INTO `messages` (`userid`,`msg`,`from`) VALUES (\''+offer.steamid_other+'\',\'toomuch\',\'System\')', function(err, row, fields) {});
return;
}
});
Help please!
Tradebot.js: