Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql> SELECT Auto_Increment FROM information_schema.tables WHERE table_name='charlist';
- +----------------+
- | Auto_Increment |
- +----------------+
- | 7 |
- +----------------+
- // Configuration.
- $username = "root";
- $password = "root";
- $hostname = "localhost";
- $dbname = "asoiaf";
- $tablename = "charlist";
- // Opens a connection to the database.
- try {
- $conn = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch(PDOException $e) {
- echo $e->getmessage();
- }
- // Gets all the information from POST.
- $autoidquery = "SELECT Auto_Increment FROM information_schema.tables WHERE table_name='$tablename'";
- $id = $conn->query("SELECT Auto_Increment FROM information_schema.tables WHERE table_name='$tablename'");
- // This should output the auto-incremented primary key, but nothing is output.
- echo $id."<br>Hello world";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement