check
$stmt=$mysqli->prepare("select max(id) as id from pickup");
$stmt->execute();
$stmt->bind_result($id);
$stmt->fetch();
$ret_id = $id;
$stmt->close();
$mysqli->close();
return $ret_id;
Pregunta
I am attempting to retrieve the latest id from the DB and it works in my terminal but will not work as a prepared statement.
Here is my code.It all works up to it, inserting and pulling a id if it is not through the max function.
$stmt=$mysqli->prepare("select id from pickup where id in (select max(id) from pickup)");
$stmt->bind_result($id);
$stmt->fetch();
$stmt->close();
$mysqli->close();
return $id;
Solución
check
$stmt=$mysqli->prepare("select max(id) as id from pickup");
$stmt->execute();
$stmt->bind_result($id);
$stmt->fetch();
$ret_id = $id;
$stmt->close();
$mysqli->close();
return $ret_id;