http post with data from variable?

Hi
am using a variable in my http post message which is getting data from the select query as follows. if i use some values assigned to that variable , http post works fine but if i use the data of select query its not working...what could be issue?

#!/bin/bash
export ORACLE_HOME=/oracle/product/9.2.0
export PATH=$PATH:$ORACLE_HOME/bin
smstext=$(sqlplus -s asdf/wert@db  <<END
set feedback off;
set heading off;
select 7 from dual;
exit;
END)
echo $smstext
(sleep 4; echo "GET  /cgi-bin/sendsms?username=zxc&password=qwe&to=123456789&text=$smstext HTTP/1.1"; echo
""; sleep 5) | telnet 10.10.10.10 9000
smstext=ownvalue
(sleep 4; echo "GET  /cgi-bin/sendsms?username=zxc&password=qwe&to=123456789&text=$smstext HTTP/1.1"; echo
""; sleep 5) | telnet 10.10.10.10 9000

The second one is working i.e smstext with assigned value "ownvalue".
but not the first one....echo $smstext responding correctly...

pls help me....

$smstext probably needs to be in quotes.

that i tried....its not ok.

Hi,

I found out the problem,

Its the blank line which creates problem in the data assigned from sql query. after removing it became ok....

smstext1=`echo $smstext | sed -e 's/\n//'`