Jump to content

SQL Problem


Recommended Posts

Posted

There is an error here in the debug script : Database query failed: No such column: false

Attempt to the length of local 'gname' (a boolean value)

The database "Government_members" exists and so does "govName"

  
local nam = getAccountName(getPlayerAccount(player)) 
local gname = executeSQLQuery("SELECT govName FROM Government_members WHERE name = ?", nam) 
if #gname >= 1 then 
  

Posted

I tested it and I see where's the problem now. You didn't put the quotes where the name gets inserted. So this should work:

local gname = executeSQLQuery("SELECT govName FROM Government_members WHERE name = '?'", nam) 

Posted

If this is the problem, the wiki for executeSQLQuery should be updated :-)

local result = executeSQLQuery("SELECT money FROM players WHERE name=?", playerName) 

May be, the space between = and ? is also a problem :)

Posted

Then the wiki part is wrong. If you see it in "pure" sql, then you can do a

"SELECT whatever FROM table where whatever = 1" This is correct for a numerical value.

For Chars, Varchars or Text it should be "SELECT whatever from table where whatever = '1' "

;-)

Posted

Well this is what i use for my spawn system and it works fine;

  
            local teams = executeSQLQuery("SELECT team FROM Spawn WHERE name = ? AND city = ?",tostring(spawn), tostring( location )) 
  

Ill test the one you put Crystal and get back.

Posted

Oh, if that works fine, that means the function puts the quotes automatically. But the problem in your script probably comes from getAccountName return value. From the error you wrote, it seems to return false, so the quotes aren't put around it, unlike strings. You need to check what it returns before executing the query.

Posted

Yes you are right Crystal its not the database error its the nam,

  
function onLogin(source) -- using it like this onPlayerLogin was the problem. 
  

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...