Click here to Skip to main content
16,016,022 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when i split textarea string into array the problem is that
next line is showing length plus one from second array data plus one though i
have used trim still not showing proper length i have entered data in textarea as
follows
9021632082
9762471857
9888888888
8888888888
problem is that first array index shows length 10
and rest of the array index shows data length 11 which is wrong
but data is of only 10 digits then no idea
please help
here is below my code
XML
<!--#include file="common.asp"-->
<!--#include file="adminheader.asp"-->
<%
    response.Expires=-1
    flag=request.Form("flag")
  if flag=1 then
       OpenDataBase_macd conn
       tostore=""
       cantstore=""
       alreadystore=""
       invalidmobilenumbers=""
    mobilenumber=trim(request.Form("mobilenumber"))
         if  mobilenumber="" then er=er & "<br><font color='red' size=2><center>Please Type Numeric Mobile Number</center></font><br>"
        if er="" then
            mobilenumberarray=split(mobilenumber,vbCr)
           'response.Write  ubound(mobilenumberarray) & "<br>"
            for i=0 to ubound(mobilenumberarray)
                if isnumeric(trim(mobilenumberarray(i)))  then
                'commented by rajiv
                   if(len(trim(mobilenumberarray(i)))=>10)  then
                  set rs=server.CreateObject("adodb.recordset")
                  'mobilenumberarray(i)=right(mobilenumberarray(i),10)
                      rs.open "select  mobilenumber from  leads where mobilenumber='91"&mobilenumberarray(i)&"'",conn,1,1
                       if rs.recordcount=0 then
                           if tostore="" then
                             tostore="91"&mobilenumberarray(i)
                             sql="('91"& mobilenumberarray(i)&"',now()),"
                            else
                             sql=sql & "('91"&mobilenumberarray(i)&"',now()),"
                             tostore=tostore & ",91" & mobilenumberarray(i)
                            end if 'tostore
                        else
                           if alreadystore="" then
                             alreadystore=mobilenumberarray(i)
                            else
                             alreadystore=alreadystore & "," & mobilenumberarray(i)
                            end if 'cantstore
                       end if 'rs.recordcount
                'conn.execute "insert into  leads(mobilenumber,dtime) values('91"& mobilenumberarray(i) &"', now() ) "
                       rs.close
                       set rs=nothing
                      else
                          if invalidmobilenumbers="" then
                             invalidmobilenumbers=mobilenumberarray(i)
                           else
                             invalidmobilenumbers=invalidmobilenumbers & "," & mobilenumberarray(i)
                           end if 'invalidmobilenumbers
                   end if 'len
                   else
                      if invalidmobilenumbers="" then
                             invalidmobilenumbers=mobilenumberarray(i)
                           else
                             invalidmobilenumbers=invalidmobilenumbers & "," & mobilenumberarray(i)
                           end if 'invalidmobilenumbers
                 end if  'isnumeric
            next
            sql="insert into  leads(mobilenumber,dtime) values"&sql
            sql=left(sql,len(sql)-1)
            'response.Write(sql)
            if tostore<>"" then
              conn.execute sql
            end if
              if tostore<>"" then
            response.Write("<font color='green' size=2><center>Mobile Numbers Stored Successfully </center></font><br>")
              end if
             'if invalidmobilenumbers<>"" then
            'response.Write("<font color='red' size=2><center>Invalid Mobile Numbers not Stored are " & invalidmobilenumbers & "<br> </center></font><br>")
            '  end if
         else
         response.write  er
        end if
  end if 'flag

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Import Mobile Clients</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="left" style="padding-left:20px;padding-top:20px;padding-bottom:15px;"><strong><font color="#3333CC" size="4">Upload Mobile Leads </font></strong></div>
<form  name="uploadmobileleads"   action="uploadmobileleads.asp"  method="post">
<%
'confirm=request.querystring("confrim")
'if confirm="" then
%>
<table >
<tr>
<td align="left" valign="top" colspan="1">
<table >
<%
 if invalidmobilenumbers<>"" then
                 invalidmobilenumbersarr=split(invalidmobilenumbers,",")
                 %>
                 <tr><td>
                 <%
                 response.Write("<font color='red' size=2><center> Invalid Mobile Numbers  listed below</center></font> ")
                 %>
                 </td></tr>
                 <%
                 for i=0 to ubound(invalidmobilenumbersarr)
                 %>
                 <tr><td align="center" valign="top">
                 <%
            response.Write(invalidmobilenumbersarr(i) & "<br> ")
                 %>
                 </td></tr>
                 <%
                 next
              end if
%>
</table><!-- inner table closed-->
</td>
</tr>
<tr>
<td align="left" valign="top" colspan="2">
<table  id="2">
<%
 if alreadystore<>"" then
                 alreadystorearr=split(alreadystore,",")
                 %>
                 <tr><td>
                 <%
                 response.Write("<font color='red' size=2><center> Mobile Numbers already exist listed below</center></font> ")
                 %>
                 </td></tr>
                 <%
                 for i=0 to ubound(alreadystorearr)
                 %>
                 <tr><td align="center" valign="top">
                 <%
            response.Write(alreadystorearr(i) & "<br> ")
                 %>
                 </td></tr>
                 <%
                 next
              end if
%>
</table><!-- id=2 inner table closed-->
</td>
</tr>
<tr><td colspan="2" valign="top"><strong>Enter Mobile Number as  9762471857 followed by Enter</strong> </td></tr>
<tr><td align="left" valign="middle">Mobile Number</td>
<td align="left" valign="middle"><textarea  rows="30"  name="mobilenumber" ></textarea></td>
</tr>
<tr>
<td>
</td>
<td>
<input type="hidden" name="flag"  value="1">
<input type="submit" name="submit"  value="Import"></td>
</tr>
</table>
<%
'else
'end if
%>
</form>
<% 'conn.close %>
</body>
</html>
Posted
Comments
Sergey Alexandrovich Kryukov 13-Jul-11 13:04pm    
Do not re-post. You should use "Improve question" on your previous question instead.
--SA

Sorry, I could not get time to analyze this code and find the problem. First look at it tells me it hardly would make much sense. Look at just one detail: string literal "91" is repeated 6 times. What if later on you want to change it. This is not supportable. There should not be hard-coded immediate constants at all. This coding has almost nothing to do with real programming and will lead nowhere. If you continue working like this, you will invite all kinds of errors.

—SA
 
Share this answer
 
Try debugging your source to see if you can understand why this could be happening.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900