your error is line 3...
<?php $db = mysqli_connect("localhost", "root", "3308") or die(mysqli_connect_error()); mysqli_select_db($db, "booksdb") or die(mysqli_error($db));
line 3 is $db = mysqli_connect("localhost", "root", "3308") or die(mysqli_connect_error());
I have not used mysqli howerver it will be close to mysql which I am still learning.
What I would try is combining the 2 lines above to this:
$db = mysqli_connect("localhost", "booksdb", "TABLEname") or die(mysqli_connect_error());
Good luck