Jump to content

Few problems


Seif

Recommended Posts

I encountered a few problems with getElementData and mysql_escape_string.

For some odd reason, this line is giving me 2 warning/errors:

local name = mysql_escape_string(serversql, getElementData(id, "name"))

mysql_escape_string is from a module but it's well used. The error says "Bad Argument @ 'getElementData'". How?

"id" is going through a loop under an element that I created.

for id in ipairs(getElementsByType("customelement")) do

And of course the element is created before the function is called(this is called when the resource stops and the element is created when the resource starts). That's how I made it:

local id = createElement("customelement", row[2])

What is wrong?

My other problem is pretty similar. when I try to compare getElementData, it says also bad argument. I suppose it's related.

Link to comment

What does the table/array you loop through look like?

When looping through arrays in lua you usually use "for key, value in ipairs [...]"

I don't know if you didn't specify a variable for holding the value of the current on purpouse but in any case "id" will always hold the key(index) to an array's field.

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...