0

Im trying to get the id that i just created in my register page and pass it to the second page which is mahai.php which this page will get the last id(new created record) and show the details of the last id. I had tried different kinds of way passing the id but the end the mahai.php?= behind is empty and this current code is having fatal error on the query I need help and recommendation in enhance my code

$connect = mysql_connect("localhost","root","","phplogin");

$queryreg = mysql_query("INSERT INTO event VALUES('','$uid','$etittle','$ebuilding')");

if ($connect->$queryreg===TRUE){
   $last_id = $conn->insert_id;
   header("Location:mahai.php?id=".$last_id);
}else{
   echo "fail";
}
Anthony FSS
  • 50
  • 1
  • 10
  • You seem to be creating `$queryreg` using one database connection, then executing it using another. What's the fatal error? – Kenney Jan 30 '16 at 15:15
  • You should not make another mysql_connect. You can and must use same one if you want to get last inser id. – Jan Rydrych Jan 30 '16 at 15:17
  • You seem to be MIXING UP the `mysql_` database extension **which you should not be using** and either the `mysqli_` or `PDO` database extensions – RiggsFolly Jan 30 '16 at 15:19
  • `mysql_*` functions don't support OOP. Please stop using the **deprecated and as of PHP7 removed** mysql_* functions. Migrate to PDO and start using Prepared Statements. – Charlotte Dunois Jan 30 '16 at 15:19

0 Answers0