I'm a php newbie, and I am having issues getting a search result to return after when trying to get results from an access database. Can anyone spot any glaring issues with the following code? I want it to search the database of books (with author and title in the table) and return the author/book name. Any help is much appreciated! Thanks!
<body>
<div id="wrapper">
<div id="content">
<h1>Search for a book</h1>
<p>You may search by author or title</p>
<form method="post" action="assignment3.php" >
<input type="text" name="search">
<input type="submit" name="submit" value="Search">
</form>
<br />
<?php
if(isset($_POST['submit'])){
echo "<h2>Search Results</h2>";
$author=filter_input (INPUT_POST, 'author');
$title=filter_input (INPUT_POST, 'title');
$conn = new COM("ADODB.Connection") or die ("Cannot start ADO");
$connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="assignment3.mdb"; //connect to database
$conn->open($connString);
$search_data("SELECT author, title FROM AuthorTitle WHERE author LIKE '%".$_POST['search']."%') OR title LIKE '%".$POST['search']."%'");
if(($search_data)!=0){
$rs=$searchquery;
}
?>
<?php if(($searchquery)!=0) {
do {
echo "<p>'.$author.' ',' '.$title.'</p>";
} while ($rs=($searchquery));
}
else {
echo "No results.";
}
}//end if
?>
</div> <!--end content-->
</div> <!--end wrapper-->
</body>
</html>
$search_data("SELECT author, title FROM AuthorTitle WHERE author LIKE '%".$_POST['search']."%') OR title LIKE '%".$POST['search']."%'");
What exactly are you trying to do here? This seems totally wrong to me. And this here$connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="assignment3.mdb"; //connect to database
Is wrong too since you forgot to delimiter the string properly. If you check the syntax highlighting here, you will see the problem. – Realitätsverlust