Jump to content

MySQL 1064 error on "UPDATE"


Recommended Posts

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:

spacer.png

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
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

  • Thanks 1
Link to comment
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.

  • Like 1
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...