ethershade Posted October 12, 2009 Share Posted October 12, 2009 Alright, For sheer arguments sake instead of getting into reasoning, me and a friend have decided to use the MTA-MySQL Module as opposed to the SQL database. My first question is: Since it appears that there are two MySQL plugins to choose from, is the version by Alberto Alonso better then the supposed actual one (at least I think there is an actual one by the MTA developers). Second question: How do we extract data from the result? As opposed to SA:MP, MTA's mysql module is a lot more advanced, though confusing at times, to utilize. local accresult = mysql_query(masterMysqlHandle, "SELECT id FROM account WHERE [u]user[/u]='"..username.."'") if (mysql_num_rows(accresult) == 1) then outputChatBox("(ACCOUNT) Your username is already registered on the server.", playerid) mysql_free_result ( accresult ) return end mysql_free_result ( accresult ) For some reason, that returns an error 'bad argument #1 to 'mysql_num_rows' (LuaBook.mysqlResult expected, got nil)' Third question: Can we free the result immediately after we do the query, or do we free it after were done with what we need. EX local accresult = mysql_query(masterMysqlHandle, "SELECT id FROM account WHERE user='"..username.."'") mysql_free_result ( accresult ) if (mysql_num_rows(accresult) == 1) then outputChatBox("(ACCOUNT) Your username is already registered on the server.", playerid) return end Request: If possible, can someone post a few lines of code to demonstrate the proper way of retrieving data using the MySQL Module [uPDATE] I found the problem, I was using 'name' as a field title thing, I forgot that you can't, I renamed the field and updated the script. Tried it and it works now. I'm such an idiot, I remember SAMP crashing from this same problem. The free result thing still needs to be answered though, if someone is willing. Link to comment
Mr.Hankey Posted October 12, 2009 Share Posted October 12, 2009 You do free the result after you've retrieved all the data from it that you need. I would suggest you just do the query, store the needed result values as variables and then free the result. 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