Hi all!<BR><BR>I created a function to get data from a database, assign a variable to it and parse the data and compare it with a given data. The problem is the function is not behaving correctly, i.e. it assumes the data is empty. Here is the code:<BR><BR>function getData(id)<BR>{<BR> var verifyData;<BR> var Conn = Server.CreateObject ("ADODB.Connection");<BR> Conn.Open ("MyDB", "MyUserid", "MyPasswd");<BR> var sql = "SELECT data FROM Table";<BR> sql += " WHERE userid = &#039" + id + "&#039";<BR> var rs = Conn.Execute (sql);<BR> <BR> if (!(rs.EOF))<BR> {<BR> verifyData = (rs(0));<BR> var exists = parseData(verifyData);<BR> return exists;<BR> }<BR> <BR> rs.Close();<BR> Conn.Close();<BR> return false;<BR>}<BR><BR>This first part gets the data from the database. Since the userid is unique, there&#039s only one occurence of the data, hence (rs(0)).<BR><BR>function parseData(str)<BR>{<BR> var tempStr = "";<BR> var item = str;<BR> for (var i=0;i&#060;item.length;i++)<BR> {<BR> var ch=item.charAt(i);<BR> if (ch == ",")<BR> {<BR> if (tempStr == some_data)<BR> {<BR> some_data = item;<BR> return true;<BR> }<BR> tempStr = "";<BR> }<BR> else if (ch != ",")<BR> {<BR> tempStr += ch;<BR> }<BR> }<BR> if (tempStr == some_data)<BR> {<BR> some_data = item;<BR> return true;<BR> }<BR> else if (tempStr != some_data)<BR> {<BR> item += ",";<BR> item += some_data;<BR> some_data = item;<BR> return false;<BR> }<BR>}<BR><BR>The objective of this function is to parse the string (stored in the format of 1a,1b,1c,...etc.) If let&#039s say, some_data = 1b; it will return a flag true (because there&#039s an occurence of 1b in the string). But it behaves as 1b does not occur in the string, thus appending it to the current string (item). I am confused. Can somebody please check this out? Thanks in advance...<BR><BR>B. Agil.