Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query output !

Status
Not open for further replies.

da21

Programmer
Dec 4, 2002
23
US
Looking for some kind help on this ! i am in puting Fluffy in the text field created in thw shopping cart.And the output resultis giving me: Fluffy Fluffy
Am I making some big mistake or is it sql query spaces ! Please help !

<html>
<body>

<%
Class.forName(&quot;org.gjt.mm.mysql.Driver&quot;).newInstance();
connection = DriverManager.getConnection(connectionURL, &quot;root&quot;, &quot;samans&quot;);
statement = connection.createStatement();
out.println(&quot;<b>&quot; + request.getParameter(&quot;tex&quot;) + &quot;</b>&quot;);
String nam = (request.getParameter(&quot;tex&quot;));
out.println(&quot;<b>&quot; + nam + &quot;</b>&quot;);
rs = statement.executeQuery(
&quot; select * &quot;
+ &quot; from pet &quot;
+ &quot; where name = ' &quot; + nam + &quot; ' &quot;);
while (rs.next()) {
out.println(rs.getString(&quot;nam&quot;));
}

rs.close();
%>

</body>
</html>
 
I just wanted to add that i am working with mysql where I am using a table pet where 'Fluffy' exists.the output is coming for the first two print statement.But the third is empty!!
 
the output is giving fluffy twice because u print it twice:
out.println(&quot;<b>&quot; + request.getParameter(&quot;tex&quot;) + &quot;</b>&quot;);
String nam = (request.getParameter(&quot;tex&quot;));
out.println(&quot;<b>&quot; + nam + &quot;</b>&quot;);


Known is handfull, Unknown is worldfull
 

that's true! But i am unable to figure out the proble, in my third print out, why is that coming empty !
 
o.k try this:
String sql=&quot; select * from pet where name = ' &quot; + nam + &quot; ' &quot;;
out.println(sql);
try running the query in mysql. see if it does return a record...
rs = statement.executeQuery(sql);


Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top