PDA

View Full Version : Infinite loop issue


YogaDownload
08-20-2008, 07:40 PM
Hello!

So, I'm not a coder, but I do know a tiny bit about it so I can attempt to solve problems that arise with my website. I have been having issues with the CPU being taken up 100% every so often by a process, and was told by my hosting company that the issue is coming from http://www.yogadownload.com/products.asp?perpage=5 which causes an infinite loop. I found this code below in the page /inc/inc-showproducts.asp and think this is where the issue lies. Can someone look over this and see if you can find what is causing the problem? Any help would be MOST appreciated!


Page:

<%if curPage > 1 then %>

<a href="<%=pFile%>curPage=<%=1 %>" class="blacklink"> << First </a>
<a href="<%=pFile%>curPage=<%=curPage-1 %>" class="blacklink"> < Prev </a>
<%end if %>

<%
if rsprod.PageCount <= 5 then
pstd=1
ped=rsprod.PageCount
else
if cInt(curPage) < 5 then
pstd=1
ped=5
elseif cInt(curPage) >= rsprod.PageCount or cInt(curPage) = cInt(rsprod.PageCount-1) then
pstd=(rsprod.PageCount-5)
ped=rsprod.PageCount
else
pstd=curPage-5
ped=curPage+5
end if
end if
%>

<%for i= pstd to ped %>
<a href="<%=pFile%>curPage=<%=i%>" class="blacklink"> <% if cint(curPage)=cint(i) then%><b> <%=i %></b><% else %><%=i %><% end if %></a>
<%next %>

<% if ((curPage+1) <= (rsprod.PageCount)) then%>
<a href="<%=pFile%>curPage=<%=curPage+1 %>" class="blacklink"> Next > </a>
<a href="<%=pFile%>curPage=<%=rsprod.PageCount %>" class="blacklink"> Last >> </a>
<%end if %>

YogaDownload
08-21-2008, 12:36 AM
Anyone?! :confused:

technica
08-21-2008, 06:30 AM
Instead of for try using the while loop and be sure that you are incrementing the loop variable i.e. i (i=i+1) after loop completion

Hope it helps

SSJ
08-21-2008, 01:41 PM
Try to debug the code against the value of pstd and ped. You will definitely find what's going wrong...