Hello all,
I am beginning to learn SQL and I have made a basic .mdb table. I am trying to have a page where the user selects a book category and when they click on it, the next page will have the book content & author within the book category they chose. I currently only have 1 book and author listed per category to keep it simple for now.
Initially the server was selecting the very first book within the database for all book category selections, so I tried to incorporate the user chosen category, but now I am getting an error. The error is: "Fatal error: Uncaught exception 'com_exception' with message Source: Microsoft Office Access Database Engine
Description: Syntax error (missing operator) in query expression 'author='.' in E:\server\Database\moredetails2.php Stack trace: #0 E:\server\Database\moredetails2.php(20): com->Execute('SELECT Books, C...') #1 {main} thrown in E:\server\Database\moredetails2.php on line 20"
My code for the page is:
<?php $authorid=filter_input(INPUT_GET, "author");
Source=../Database/poe.mdb"; //creates the connection object and define the connection string
$conn->Open($connString);
$selectCommand="SELECT Books, Content FROM Authors WHERE author=$authorid;";
$rs = $conn->Execute($selectCommand);
//opens a recordset from the connection object
if (!$rs->EOF){
$BookName=$rs->Fields("Books");
$AuthorName=$rs->Fields("Author");
$Content=$rs->Fields("Content");
}
print "Book: $BookName<br>"; print "Author: $AuthorName<br>"; print "$Content<br><br>";
$rs->Close;
?>
I cut out the initialize bits, but I can add them if that is helpful.