Jump to content

Recommended Posts

Posted

Hello

 

I'm fairly new to RAGEMP development using JS

 

So i have this function 

sql.js : 

module.exports = function SQLQuery(player,sql,returning = 0)
{
    connection.query(sql, function (err,result) {
    if (err) {
      console.log('[SQL-ERROR] : ' + err);  
      throw err;
    }
    else
    //do stuff
    if(returning != 0)
      return result;

});
}
//or exporting using this >> module.exports.SQLQuery = SQLQuery();

 

im trying to read the "results" I've returned from the SQLQuery function in my LoginReg.JS file

which looks like this :

const sql = require("./mysql.js")();

function SocialClubCheck(player,clubid)
{
     var exists = sql.SQLQuery(player,`SELECT COUNT * FROM accounts WHERE rockstar_id = ${clubid}`,1);
    if(exists[0] != 0 )
        console.log(`account with ${clubid} FOUND! `);
    else
        console.log(`account with ${clubid} NOT FOUND! `);

}

 

but i don't think I'm doing it the right way

 

i keep getting this error : 

TypeError: Cannot read property 'SQLQuery' of undefined
     var exists = sql.SQLQuery(player,`SELECT COUNT * FROM accounts WHERE rockstar_id = ${clubid}`,1);

 

i would like any kind of hints of what am i doing wrong here

 

Thanks

  • 3 weeks later...
Posted

You're calling your exported function here

const sql = require("./sql.js")();

 

Try 

const sql = require("./sql.js");

// then 

var exists = sql(player,etc etc

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...