.:HyPeX:. Posted January 15, 2015 Share Posted January 15, 2015 Well, i cant check if the serial was already introduced, it simply does not retrive the values.. function addNewTime(map,player,serial,time,name,country,date) local map = getMapName(map) outputChatBox(map) local query = dbQuery(Database,"SELECT * FROM "..md5(map).." WHERE serial = '"..serial.."';") local result = dbPoll(query,-1) local g_Time=nil local vask = nil if result then outputChatBox("rowing") for _,row in ipairs(result) do outputChatBox("rowing2") for column,value in ipairs(row) do outputChatBox(column) outputChatBox(value) outputChatBox(column.." "..value) if column == "serial" then if value == serial then vask = true end elseif column == "time" then g_Time = value end end end if not vask then local query = dbQuery(Database,"INSERT INTO "..md5(map).." (serial,name,time,country,date) VALUES ('"..serial.."','"..name.."','"..time.."','"..country.."','"..date.."');") local result = dbPoll(query,-1) if result then outputChatBox("top added!") else outputChatBox("top not added!") end Output: Hypex-Testtopmap rowing rowing2 rowing2 top added! Table in mysql.. http://i.imgur.com/V4MAVHK.png Thanks in advance Link to comment
novo Posted January 15, 2015 Share Posted January 15, 2015 That's because "result" contains the table's values as arrays with respective index to each column name. for i, row in ipairs(result) do outputChatBox(row.serial) outputChatBox(row.name) end Either way, I recommend you to use dbQuery as follows: (Note: It is usually good practice to surround table and column names with backticks (`) in case they contain spaces or SQL keywords (and therefore cause syntax errors). This is especially true when using variables for table and column names, as potential problems may not be apparent when the script is first written. @dbQuery) dbQuery(Database, "SELECT * FROM ? WHERE serial = ?", md5(map), serial) Link to comment
.:HyPeX:. Posted January 15, 2015 Author Share Posted January 15, 2015 Thanks, and about the braticks part, i'll check later on. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now