Jump to content

[SOLVED] IMPORTANT --- ERROR MESSAGE MAKING ME FEEL STUPID


kaimason1

Recommended Posts

Unknown column 'Book' in 'where clause'

 

Now I'm getting this error... help?

 

EDIT::

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
  <TITLE>My Search</TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
</HEAD>
<BODY>
  <FORM METHOD="get" action="search.php">
   <P>Please enter your search words here and specify the type of data you input: <INPUT type="text" name="search" size=30 maxlength=70>
    <SELECT name="type" size="1">
     <OPTION value="Title">Title</OPTION>
 <OPTION value="Author">Author</OPTION>
 <OPTION value="Genre">Genre</OPTION>
 <OPTION value="Page_Count">Page Count</OPTION>
 <OPTION value="Reading_Level">Reading Level</OPTION>
 <OPTION value="ISBN">ISBN</OPTION>
    </SELECT>
   </P>
   <INPUT type="submit" name="submit" value="Submit">
  </FORM>
</BODY>
</HTML>
<?php
if(isset($_GET['submit']) && $_GET['submit'] == "Submit") {
//Connect to database//
include("usernamepassworddatabase.php");
mysql_connect(localhost,$username,$password)or die("I couldnt connect, sir. By the way, am I being paid for acting like a personal butler?");
mysql_select_db($database)or die("The database you are trying to access is currently unavailable. Curious...");
//Retrieve variables from HTML form
$search=trim(mysql_real_escape_string($_GET['search']));
$type=trim(mysql_real_escape_string($_GET['type']));
//Create MySQL query//
if($search == "") {
die("Please enter a search.");
} else if($type == "Title") {
$query="SELECT * FROM TEST1_contacts WHERE 'Book' LIKE '%$search%'";
} else if($type == "Author") {
$query="SELECT * FROM TEST1_contacts WHERE 'Author' LIKE '%$search%'";
} else if($type == "Genre") {
$query="SELECT * FROM TEST1_contacts WHERE 'Genre' LIKE '%$search%'";
} else if($type == "Page_Count") {
$query="SELECT * FROM TEST1_contacts WHERE 'Page_Count' LIKE '%$search%'";
} else if($type == "Reading_Level") {
$query="SELECT * FROM TEST1_contacts WHERE 'Reading_Level' LIKE '%$search%'";
} else if($type == "ISBN") {
$query="SELECT * FROM TEST1_contacts WHERE 'ISBN' LIKE '%$search%'";
} else{
die("Congratulations -- you achieved the impossible rating of hacker. How else did I receive an inaccurate data type, hmm?");
}
//Search Results//
$result=mysql_query($query) or die (mysql_error());
$num=mysql_num_rows($result);
if($num == 0) {
die("There seems to be no records matching your search. Interesting...");
} else{
$i=0;
while($i<$num){
	$book=mysql_result($result,$i,"Book");
	$author=mysql_result($result,$i,"Author");
	$genre=mysql_result($result,$i,"Genre");
	$page_count=mysql_result($result,$i,"Page_Count");
	$reading_level=mysql_result($result,$i,"Reading_Level");
	$ISBN=mysql_result($result,$i,"ISBN");
	echo("<b>$book</b> by $author.<br>$genre.<br>$page_count pages.<br>$reading_level reading level.<br>ISBN:$ISBN<br><hr><br>");
	++$i;
}
}
}
php?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.