hi

  try to use "'" around the new value.
  I.E.

   rs = stmt.executeQuery("SELECT * FROM MyTable WHERE title_name='"
+ request.getParameter("title_name") ) + "'";

/david


-----Original Message-----
From: Lucy [mailto:[EMAIL PROTECTED]]
Sent: den 30 maj 2001 15:09
To: [EMAIL PROTECTED]
Subject: Servlet SELECT Query syntax error


Hi
Error message "You have error in your SQL syntax" ... Using Apache Tomcat -
MySQL in Win 2000.
Scenario:  Servlet collects form data value, sends query to MySQL, returns
search.  The problem is getting
the value of the inputted parameter named, title_name.  Problem coding:

rs = stmt.executeQuery("SELECT * FROM MyTable WHERE title_name="  +
request.getParameter("title_name") );

I've tried various combos after the problem part** WHERE title_name=" **
such as double quotes, single, both, ?, ;,spaces, also replacing with String
alternatives eg.,
   String param1;
   param1 = request.getParameter("title_name");
   rs = stmt.executeQuery("SELECT * FROM MyTable WHERE title_name = " +
param1);

I've checked parameter name matches html form, servlet and database and that
rs closes OK.  Any ideas?  Cheers, Lucy


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to