Open emaxerrno opened 11 years ago
First. database/sql doesn't handle properly multiple results. Your query contains INSERT and SELECT. Each one returns some result and you can't obtains them using database/sql, because it assumes only one result per query. If you really need such functionality use raw mymysql (not database/sql).
Second. You probably use db.Query or db.Prepare. Prepared statements can't contain multi-statements, see: http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-prepared-statements.html
Working sql. Tested pasting this text on the shell.
INSERT INTO users (email, password, status, signup_date, zipcode, fname, lname) VALUES ( 'a@a.com', 'asdf', 'unverified', now(), '111', 'asdf', 'asdf' ); SELECT LAST_INSERT_ID();
Error by using ? where the quotes are like this
That will cause a:
Cannot create new user sql prepared statement:Received #1064 error from MySQL server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select last_insert_id()' at line 1"