DarkStalker30 Posted September 14 Share Posted September 14 Hello everyone, I have a problem with database. I'm trying to add outfit into database and update player's info, but every time I'm getting this trouble: String to use: local insertString = "INSERT INTO `inventories`(`inventory_type`, \ `inventory_big_sells`, `inventory_mid_sells`, `inventory_small_sells`, \ `inventory_max_weight`, `inventory_owner_id`) VALUES \ ('outfit','0','0',?,'-1',?);\ UPDATE `chars_invs` SET `char_inv_outfit`=? WHERE `char_inv_id`=?;" It looks like correct SQL code. In phpMyAdmin SQL field I tried too, and it didn't create any errors, but in MTA it's not work. I can guess that because nearby "UPDATE" appears ', but I don't know how to fix that. Any ideas? Link to comment
Moderators IIYAMA Posted September 14 Moderators Share Posted September 14 18 minutes ago, DarkStalker30 said: It looks like correct SQL code Are you sure those newlines are correct? As far as I can remember the following is considered a newline in Lua: \n Or auto newlines: local test = [[ newline newline newline newline ]] But I can be mistaken, maybe MySQL also accepts your way. Also make sure multi_statements is enabled, see: https://wiki.multitheftauto.com/wiki/DbConnect 1 Link to comment
DarkStalker30 Posted September 14 Author Share Posted September 14 1 hour ago, IIYAMA said: Are you sure those newlines are correct? As far as I can remember the following is considered a newline in Lua: \n Yes, I've already did strings like that, and it works correctly (not when I'm trying to do multiple statement). I can't remember, where I found it, but it was on MTAWiki 99%, or some resource which was referenced by wiki. Example: local insertString = "INSERT INTO `houses`\ (`house_owner_id`, `house_enter_x`, \ `house_enter_y`, `house_enter_z`, `house_enter_rotation`, \ `house_exit_x`, `house_exit_y`, `house_exit_z`, \ `house_exit_world`, `house_exit_dimension`, `house_exit_rotation`, \ `house_interior_type`, `house_base_price`, `house_current_price`) \ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);" Works 100% good, no errors or data corruption in tables. 1 hour ago, IIYAMA said: Also make sure multi_statements is enabled, see: I didn't knew about this, I'll check. But if the problem in that flag, this is weird, that error by MySQL. 1 hour ago, IIYAMA said: Also make sure multi_statements is enabled, see: https://wiki.multitheftauto.com/wiki/DbConnect Yes, this is the solution. Thank you very much, I would never have guessed where is the problem. 1 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