-1

EDIT: I am using PDO object, not MYSQLI nor am I trying to get lastId, these are not the same questions that you're marking 'duplicate' they are just different solutions.

I am having an issue with my SQL statement that I am using a PDO object for and I keep getting this error (below), I have tried several things and done some research, but I could not find anything to work. Any info on what I am doing wrong (Or if this is an illegal statement).

Thanks for any help!

Error

    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 'INSERTED.* 
INTO `visits` (`cardNum`, `purpose`, `status`) VALUES ('0','0','0') at line 1

Statement

$pdo->prepare('INSERT INTO `visits` (`cardNum`, `purpose`, `status`) OUTPUT INSERTED.* VALUES (?,?,?)');
Matthew
  • 3,136
  • 3
  • 18
  • 34

1 Answers1

2

I think on the MySQL server the OUTPUT INSERTED is not available, if the goal is to retrieve the last inserted id, then try this:

$pdo->lastInsertId();
chris85
  • 23,846
  • 7
  • 34
  • 51
websoftwares
  • 192
  • 5
  • Well, the issue with that is there is a chance another instance may insert and then my lastInsertId is now different, correct? – Matthew May 21 '17 at 21:51