I already tried:-
$last_id = $stmt->lastInsertId();
But still its not returning string nor data, its just white blank page, any idea on how to return last id using PDO ?
PHP
public function createTrip($trip_name,$trip_cost,$trip_start,$trip_end,$trip_location,$trip_description)
{
try
{
$stmt = $this->conn->prepare("INSERT INTO trips(trip_name,trip_cost,trip_start,trip_end,trip_location,trip_description)
VALUES(:trip_name,:trip_cost,:trip_start,:trip_end,:trip_location,:trip_description)");
$stmt->bindparam(":trip_name", $trip_name);
$stmt->bindparam(":trip_cost", $trip_cost);
$stmt->bindparam(":trip_start", $trip_start);
$stmt->bindparam(":trip_end", $trip_end);
$stmt->bindparam(":trip_location", $trip_location);
$stmt->bindparam(":trip_description", $trip_description);
$stmt->execute();
$last_id = $stmt->lastInsertId();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
HTML
$trip = new TRIP();
$trip>createTrip($trip_name,$trip_cost,$trip_start,$trip_end,$trip_location,$trip_description);