Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. mysql> SELECT Auto_Increment FROM information_schema.tables WHERE table_name='charlist';
  2.  
  3. +----------------+
  4. | Auto_Increment |
  5. +----------------+
  6. | 7 |
  7. +----------------+
  8.  
  9. // Configuration.
  10. $username = "root";
  11. $password = "root";
  12. $hostname = "localhost";
  13. $dbname = "asoiaf";
  14. $tablename = "charlist";
  15.  
  16. // Opens a connection to the database.
  17. try {
  18. $conn = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password);
  19. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  20. } catch(PDOException $e) {
  21. echo $e->getmessage();
  22. }
  23.  
  24. // Gets all the information from POST.
  25. $autoidquery = "SELECT Auto_Increment FROM information_schema.tables WHERE table_name='$tablename'";
  26. $id = $conn->query("SELECT Auto_Increment FROM information_schema.tables WHERE table_name='$tablename'");
  27. // This should output the auto-incremented primary key, but nothing is output.
  28. echo $id."<br>Hello world";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement