Jump to content

MarPlo

Members
  • Posts

    80
  • Joined

  • Last visited

Posts posted by MarPlo

  1. Hy,

    Here's an example that gets the las inserted id (I use MySQLi):

    <?php
    // connect to the "tests" database
    $conn = new mysqli('localhost', 'root', 'pass', 'tests');
    
    // check connection
    if (mysqli_connect_errno()) {
      exit('Connect failed: '. mysqli_connect_error());
    }
    
    // sql query for INSERT INTO users
    $sql = "INSERT INTO `users` (`name`, `pass`, `email`)
    VALUES ('PloMar ', 'love_light', 'a_name@domain.net')"; 
    
    // Performs the $sql query and get the last insert auto ID
    if ($conn->query($sql) === TRUE) {
      echo 'The auto ID is: '. $conn->insert_id;
    }
    else {
    echo 'Error: '. $conn->error;
    }
    
    $conn->close();
    ?>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.