php - mysql_insert_id() always returns 0 -


I am trying to retrieve the last id number entered with mysql_insert_id (), but always return 0, My ID field is auto increment so I do not know why it gives 0 thanks. Please help

  include 'C: \ xampp \ htdocs \ student_evaluation \ functions.php'; If (! Login ()) {Header ("Location: http: //localhost/dev/userarea.php"); Go out(); } If (isset ($ _ POST ['submit'])) {// data $ name = $ _POST ['name']; $ F_lastname = $ _POST ['f_lastname']; $ Second_lastname = $ _POST ['second_lastname']; $ Student_number = $ _POST ['student_number']; $ Semester_year = $ _POST ['semester_eur']; $ Course = $ _POST ['course']; $ Section = $ _POST ['section']; $ Grade = $ _POST ['grade']; $ Student_perform = $ _POST ['student_perform']; $ Comment_box = $ _POST ['comment_box']; $ sql = "` students` (`name`, 'first_ lastname`,' second_lostname`, 'number_stidinate```, semester' ',' course ',' section ',' f_grad ',' student_perform`, 'annotations') Include in the price ('$ name', '$ f_lastname', '$ second_lastname', '$ student_number', '$ semester_year', '$ course', '$ section', '$ grade', '$ student_perform' '$ Comment_box') "; $ Con = mysqli_connect ("localhost", "root", "", "remembrance"); $ Result = mysqli_query ($ con, $ sql); The echo of the previous recorded record is "id:". Mysql_insert_id (); }    

using a library ( mysqli ) In order to query, then another ( mysql ) can not work for it to get auto-increment ID, in addition to other issues, you also connect to the database with the second library Not done!

Use continuously or better, PDO, which will help you to plug your blindness safety defects.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -