Jump to content
×
×
  • Create New...
  • 0

Problem with MySQL 5.6 select query


Deucalion

Question

Hi. Maybe it's easy but, i have problem with that ;/ I have a MySQL 5.6 and Vanilla core 2.3 with db.

When I use a game.mysql_query in quest with "SELECT", and put it into chat I have a empty chat, and nothing in sysser, but when I put query into e.g "chat("something"..query.." ") i have this error in sysser:

SYSERR: Apr 26 11:31:02 :: RunState: LUA_ERROR: [string "test_quest"]:3: attempt to concatenate local `query' (a table value)
SYSERR: Apr 26 11:31:02 :: WriteRunningStateToSyserr: LUA_ERROR: quest test_quest.start click

Part of e.g quest

local query = game.mysql_query('SELECT name FROM player.player WHERE id = 70984')
	chat("something"..query.." ")

But when I use this query in navicat everything is ok.

I'll be grateful for the help :)

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

now error is a little bit different

SYSERR: Apr 26 12:38:37 :: RunState: LUA_ERROR: [string "test_quest"]:3: attempt to index field `name' (a string value)
SYSERR: Apr 26 12:38:37 :: WriteRunningStateToSyserr: LUA_ERROR: quest test_quest.start click
Link to comment
Share on other sites

  • 0
  • Moon
local query = game.mysql_query("select name from player.player where id = '700984'")

if(table.getn(query) == 0) then
	return chat("There nothing.. ")
else
	chat(query[1])
end

Test it like this

 

Kind Regards

HaveBeen

  • Love 1

Plain logic saves lives.

Link to comment
Share on other sites

  • 0

 

Now quest return empty chat

 

You're sure this query is truth?

 

Kind Regards

HaveBeen

 

right* 

@HaveBeen: Wahr/Nicht Wahr = true(truth) /false, Richtig/Falsch = right/wrong

 

 

 

best regards Xunil

Link to comment
Share on other sites

  • 0

I prefer to set a test whether the variable exists. If your query fails, the table is empty, or in the worst case, nil.

So you can test it with an if statement like that :

if query and query[1] then
-- or
if (query or {}) [1] then
-- or
chat('sth '.. ((query or {{0}})[1] or {0})[1})
the latest is pro code, you don't need to understand it, but if you do, Nice :)

With those statements you prevent syserr messages

Sent by Tapatalk @ Galaxy Note 10.1

  • Love 2
Link to comment
Share on other sites

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


Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.