izstas Posted January 25, 2008 Posted January 25, 2008 I call function: local result = call(getResourceFromName("db"), "sql_query", "SELECT ....'"); function sql_query work when I call it from resource "db", when I call it from other resource - it returns "SELECT ....". Why? Function sql_query is exported. Log: [15:54:03] ERROR: [script path has been here] : bad argument #1 to 'mysql_fetch_assoc' (LuaBook.mysqlResult expected, got string) [15:54:03] ERROR: call: Check the function exists, is exported and you've passed the correct arguments
50p Posted January 25, 2008 Posted January 25, 2008 Make sure that resource "db" exports the functions you want to call. In meta.xml <export function="sql_query" /> - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
izstas Posted January 25, 2008 Author Posted January 25, 2008 No Function calling, but I can't get what function return.
50p Posted January 25, 2008 Posted January 25, 2008 Show you sql_query function. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
izstas Posted January 25, 2008 Author Posted January 25, 2008 function sql_query(arg) return db.sql_query(arg); end; function db.sql_query(query, hideinlist) if (db.connected == false) then outputServerLog("SQL ERROR: [Error message has been here]"); return; end; queryres = mysql_query(db.connection, query); db.num_quries = db.num_quries + 1; if (hideinlist == nil) then db.quries[db.num_quries] = {["query"] = query}; else db.quries[db.num_quries] = {["query"] = "HIDDEN"}; end; if (not queryres) then outputServerLog("SQL ERROR: \n ".. query .." \n\n #" .. db.sql_errno() .. ": " .. db.sql_error()); end; return queryres; end;
50p Posted January 25, 2008 Posted January 25, 2008 Why do you use mysql_query in sql query? Also, how do you expect result from query to be a string? The result from a SQL query is stored in a result-set. Most database software systems allow navigation of the result set with programming functions, like: Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, etc. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
ryden Posted January 25, 2008 Posted January 25, 2008 I can't see the mysql_fetch_assoc call in that code.
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