GTX Posted March 16, 2012 Share Posted March 16, 2012 (edited) Hello, I tried to move from SQLite to MySQL, like: addEvent("onMapStarting", true) addEventHandler("onMapStarting", root, function(mapInfo, mapOptions, gameOptions) g_MapInfo = mapInfo mapname2 = g_MapInfo.name olddata = executeSQLQuery("SELECT playerName, timeText, playerSerial FROM `race maptimes Freeroam "..mapname2.."`") if olddata then for i, v in ipairs">ipairs">ipairs">ipairs">ipairs">ipairs">ipairs(olddata) do Date2 = getRealTime() Date = string.format("%02d/%02d/%02d", Date2.monthday, Date2.month + 1, Date2.year + 1900) outputChatBox("RETURNS: ".. tostring">tostring">tostring">tostring(olddata.playerName) .. ", ".. tostring">tostring">tostring">tostring">tostring(olddata.timeText) ..", ".. tostring">tostring">tostring(olddata.playerSerial) ..".") --mysql_query(connect_mysql, "INSERT INTO `"..mapname.."` (name, Time, Date, Serail, CTag) VALUES ('"..tostring(olddata.playerName).."', '"..tostring(olddata.timeText).."', '"..Date.."', '"..tostring(olddata.playerSerial).."','CLAN')") end end end) Returns nil I've no idea why. Do you know? EDIT: There's freaky bug in ... addEvent("onMapStarting", true) addEventHandler("onMapStarting", root, function(mapInfo, mapOptions, gameOptions) g_MapInfo = mapInfo mapname2 = g_MapInfo.name olddata = executeSQLQuery("SELECT playerName, timeText, playerSerial FROM `race maptimes Freeroam "..mapname2.."`") if olddata then for i, v in ipairs(olddata) do Date2 = getRealTime() Date = string.format("%02d/%02d/%02d", Date2.monthday, Date2.month + 1, Date2.year + 1900) outputChatBox("RETURNS: ".. tostring(olddata.playerName) .. ", ".. tostring(olddata.timeText) ..", ".. tostring(olddata.playerSerial) ..".") end end end) Thanks in advance Edited March 16, 2012 by Guest Link to comment
Kenix Posted March 16, 2012 Share Posted March 16, 2012 What return nil? request? Can you please tabulate code. Link to comment
GTX Posted March 16, 2012 Author Share Posted March 16, 2012 addEvent("onMapStarting", true) addEventHandler("onMapStarting", root, function(mapInfo, mapOptions, gameOptions) g_MapInfo = mapInfo mapname2 = g_MapInfo.name olddata = executeSQLQuery("SELECT playerName, timeText, playerSerial FROM `race maptimes Freeroam "..mapname2.."`") if olddata then for i, v in ipairs(olddata) do Date2 = getRealTime() Date = string.format("%02d/%02d/%02d", Date2.monthday, Date2.month + 1, Date2.year + 1900) outputChatBox("RETURNS: ".. tostring(olddata.playerName) .. ", ".. tostring(olddata.timeText) ..", ".. tostring(olddata.playerSerial) ..".") end end end) Why don't you test it? tostring(olddata.playerName), tostring(olddata.timeText), tostring(olddata.playerSerial) return nil Link to comment
Cadu12 Posted March 16, 2012 Share Posted March 16, 2012 olddata = executeSQLQuery("SELECT playerName, timeText, playerSerial FROM `race maptimes Freeroam "..mapname2.."`") I tinhk that's wrong at FROM. Link to comment
GTX Posted March 16, 2012 Author Share Posted March 16, 2012 And what it should be? I think it's fine here. Link to comment
GTX Posted March 16, 2012 Author Share Posted March 16, 2012 I made it working. Thank you for trying to help me. Link to comment
drk Posted March 16, 2012 Share Posted March 16, 2012 For who don't know: Correct olddata = executeSQLQuery [[ SELECT playerName, timeText, playerSerial FROM myTable WHERE myMap = 'race maptimes Freeroam "..mapname2.."' ]] Or: olddata = executeSQLQuery ( "SELECT playerName, timeText, playerSerial FROM myTable WHERE myMap = 'race maptimes Freeroam "..mapname2.."' ") Link to comment
GTX Posted March 16, 2012 Author Share Posted March 16, 2012 Nah, it wasn't that. The problem was: tostring(olddata.playerName), tostring(olddata.timeText), tostring(olddata.playerSerial) to: tostring(v.playerName), tostring(v.timeText), tostring(v.playerSerial) Link to comment
drk Posted March 16, 2012 Share Posted March 16, 2012 olddata = executeSQLQuery("SELECT playerName, timeText, playerSerial FROM `race maptimes Freeroam "..mapname2.."`")I tinhk that's wrong at FROM. I'm talking about this. 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