PDO lastInsertID problem

I’ve got this, pretty sure I understood the manual right lol

	$query=$oDB->Prepare("INSERT INTO members (fname, password, email, sector, level, troops, created) VALUES (:fname, :password, :email, :sector, :level, :troops, :created)");
	$query->execute(array(':fname' => $_POST['name'], ':password' => $_POST['password'], ':email' => $_POST['email'], ':sector' => rand(1,20), ':level' => '1', ':troops' => '0', ':created' => date("Y-m-d H:i:s")));
	
	$lastuserid = $oDB->lastInsertId();

but the last insert id dont seem to work

Did your INSERT query work?

yes, but not the next one that requires the lastinsertid variable.

Dont know what happened, but it works now. Think I actually uploaded the file into the wrong folder and kept refreshing old code lol Im sorry!

No problem. I’m glad it’s working.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.