On Wed, 16 Jul 2003 08:33:37 -0500, joemyre wrote:
Hi everyone,
What I'm trying to do is take php variables i got from user input, and
pass them as the MySQL query terms.
$query = "select * from ident where ".$searchtype1."=".$searchterm1."";
ERROR: Invalid query: You have an error in your SQL syntax near '=' at
line 1
I have also tried,
$query = "select * from ident where ".$searchtype1." like
'%".$searchterm1."%'";
ERROR: Invalid query: You have an error in your SQL syntax near 'like
'%%'' at line 1
<snip!>
Thanks again
Joe
i haven't read your post thouroughly, but here is my suggestion. First
off, how are you debugging this? I find it very useful to print to the
screen the actual SQL query being sent to the server and test it inside a
MySQL client session if I am having problems. Have you done this?
Try this. Before you pass the query to the MySQL server (using
mysql_query()), echo it to the screen, cut, and paste it into a MySQL
prompt:
$query = "select * from ident where ".$searchtype1." like '%".$searchterm1."%'";
echo "<pre>\n$query\n</pre>";
exit();
highlight, copy, and paste into mysql prompt.
does the query work?
is the query as printed in the browser quite what you expected it would
be?
later...
--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website |
http://www.wse.jhu.edu/newtnotes/