?
Solved

Inserting a Value from a table into an SMS message

Posted on 2005-04-18
5
Medium Priority
?
245 Views
Last Modified: 2010-04-01
Hi,
I have a page sending an sms message, but I want to include in the message a "UserName" from the table in the database.
The following code is what I have, and the "Phone" and "UserName" are coming from the same table.


<%@ page session="true" %>
<%@ page language="java" contentType="text/html" import="java.sql.*, java.util.*, java.lang.*, java.io.* " errorPage="errorpage.jsp" %>

<%@ page import="java.util.*" %>
<HTML>
<%
out.print("Administrator logged in: " + session.getValue("UserName")+ "<br>");
%>
                    </p>
                    <p>                
  <%
Statement     statement = null;
ResultSet     resultset = null;
ResultSetMetaData rsmd = null;
Connection     connection = null;

                Class.forName("org.gjt.mm.mysql.Driver").newInstance();
               connection = DriverManager.getConnection(
                  "jdbc:mysql://localhost/combcdte_project?user=&password=");    
statement = connection.createStatement();

String name  = "'" + request.getParameter("name") + "'";
System.out.println("user is : -->"+name); // to check if we are getting the user name correctly

ResultSet rs = statement.executeQuery("SELECT * FROM Member WHERE UserName="+name);
String user = "xxxxx";
String  password = "xxxxx";
String  api_id = "xxxxx";
String  baseurl ="http://api.clickatell.com";
String  text = "Hi, Thank you for participating "; // Part having trouble with - do I need + <%=rs.getString ("UserName")%> + // in this part or is it something different??

String  to = "Mobile";
if(rs.next())
{
out.println("found phone");
out.println("Mobile");
to =rs.getString("Mobile");
}
%>
<html>
<body>
<frame  src="http://api.clickatell.com/http/sendmsg?user=<%=user%>&password=<%=password%>&api_id=<%=api_id%>&to=<%=to%>&text=<%=text%>"></frame>
                    <p align="center">&nbsp;</p>
                    <p align="center">&nbsp;</p>
</body>
</html>
 <%
{
    connection.close();
}

%>  

This is fairly urgent so any help is welcome thanks
0
Comment
Question by:acslater
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13805247
If it's the Username from the SQL statement below

ResultSet rs = statement.executeQuery("SELECT * FROM Member WHERE UserName="+name);

 you should be able to go

String  text = "Hi, Thank you for participating " + name;
0
 

Author Comment

by:acslater
ID: 13805937
This is what im trying to use now ...

>>String  text = "Hi, " + name + " Thank you for participating

Is this the corrext syntax?
I tried

>>String  text = "Hi, + name + Thank you for participating

but just printed out :

Hi name  Thank You ...
0
 
LVL 29

Accepted Solution

by:
bloodredsun earned 2000 total points
ID: 13806069
String  text = "Hi, " + name + " Thank you for participating ";

or even better
String  text = "" ;
String  to = "Mobile";
if(rs.next())
{
    text = "Hi "+ rs.getString ("UserName") +", Thank you for participating ";
    out.println("found phone");
   out.println("Mobile");
   to =rs.getString("Mobile");
}
0
 

Author Comment

by:acslater
ID: 13806602
The bottom one worked a treat :)
Thanks
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13806798
Great!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If anyone asked you to network diagram of the internet, it was drawn in the form of a fluffy cloud which further became known as cloud computing. Popularly cloud computing is defined as workloads that run over the internet in a commercial provider’s…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question