LMSouq
general-dev Open

PDO get the last ID inserted

WI
William Kinaan
1 month ago
3 views
Problem Description
I have a query, and I want to get the last ID inserted. The field ID is the primary key and auto incrementing. I know that I have to use this statement: LAST_INSERT_ID() That statement works with a query like this: $query = "INSERT INTO `cell-place` (ID) VALUES (LAST_INSERT_ID())"; But if I want to get the ID using this statement: $ID = LAST_INSERT_ID(); I get this error: Fatal error: Call to undefined function LAST_INSERT_ID() What am I doing wrong?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base