A sample query that I am sending is:
SELECT * from tutorbase where name LIKE '%lanning%'
My database is structured as thus:
CREATE TABLE tutorbase (
id int(11) NOT NULL auto_increment,
phone varchar(15) NOT NULL default '',
email varchar(255) NOT NULL default '',
im text NOT NULL,
site text NOT NULL,
class text NOT NULL,
rate float(6,3) NOT NULL default '0.000',
comment text NOT NULL,
pass text NOT NULL,
active tinyint(4) NOT NULL default '0',
name varchar(255) NOT NULL default '',
pagetitle varchar(255) NOT NULL default '',
PRIMARY KEY (id),
KEY id (id)
) TYPE=MyISAM;
The code that I use to start the form:
<form action = "<? print($PHP_SELF); ?>" method = "post">
Search: <select name = "field" size = "1">
<option selected>phone</option>
<option>class</option>
<option>name</option>
</select><br>
Query: <input type = "text" name = "query">
<input type = "submit" name = "submit" value = "Search">
<input type = "reset" name = "reset" value = "Reset">
<input type = "hidden" name = "search" value = "1">
</form>
and the code that I use to start the MySQL transaction:
if ($search)
{
$query = "SELECT * from tutorbase where $field LIKE '%$query%'";
print("<tt>$query</tt>");
$mysql_result = mysql_result($query,$mysql_link);
print("<table border = '0' cellspacing = '1' cellpadding = '1' width = '50%'>");
print("<tr><td> </td><td><b>");
print(ucwords($field));
print("</b></td></tr>");
$x = 0;
while ($row = mysql_fetch_row($mysql_result))
{
#code goes here
}
}
Now.. when I enter in the query as it is displayed by the PHP command print("<tt>$query</tt>"); in the previous code block, PHP claims
Warning: Supplied argument is not a valid MySQL result resource in /home/zeal/www/lab/tutorbase/tutorbase.php on line 10
However, when I post this query directly into MySQL, it executes without any problem....
WHAT'S THE DEAL?