Jump to content

Take a look, it's..


denny911
 Share

Recommended Posts

Hi,on my site visitors have the option for commenting the articles. I created a database and a table for comments within the database. When a visitor wants to comment some particular article, he inserts his nick and comment into a simple form and submits it.Now, if there ARE ANY COMMENTS (at least ONE) for that article, everything will go just fine and visitor's comment will show up.BUT.. For some strange reason, if there IS NO COMMENTS for that article, after submitting the form, everything is so slowed down, page seems to be loading forever, and after some period of time an error occurs (something like YOUR SESSION HAS EXPIRED.. or TIME IS EXCEEDED..)The code i'm using to show the previous comments for some article is shown below:<%Dim komentID komentID = Request.QueryString ("komentID") set rs = Server.CreateObject("ADODB.recordset")dataSQL = "SELECT ime, komentar, vrijeme FROM komentari WHERE komentID = " & komentID & ""rs.Open dataSQL, conndo until rs.EOF for each x in rs.Fields Response.Write(x.value) next rs.MoveNextlooprs.closeset rs = nothing%>So, is there anybody who could tell me what's wrong with the code? (Maybe it's that LOOP thing?)P.S. Please, be as specific as you can be, since I'm just a beginner in ASP..Thanks, Denny

Link to comment
Share on other sites

Denny,You are right, the problem is in your loop... your are asking the cursor to go throught the recordset untill he comes to the End Of File (EOF). If the table contains any value, there is no problem. But if it's empty, it just doesn't find any End Of File, and it keeps looking and looking untill you get an error...Instead, try to use a "Do While" loop like this :

<%'...Do While Not rs.EOF And Not rs.BOF  Response.Write(rs("ime") & " " & rs("komentar") & " " & rs("vrijeme"))rs.MoveNextLoop'... %>

Link to comment
Share on other sites

Denny,You are right, the problem is in your loop... your are asking the cursor to go throught the recordset untill he comes to the End Of File (EOF). If the table contains any value, there is no problem. But if it's empty, it just doesn't find any End Of File, and it keeps looking and looking untill you get an error...Instead, try to use a "Do While" loop like this :
<%'...Do While Not rs.EOF And Not rs.BOF  Response.Write(rs("ime") & " " & rs("komentar") & " " & rs("vrijeme"))rs.MoveNextLoop'... %>

well, jerome, thanks for your reply--i'll try it right now..
Link to comment
Share on other sites

You're welcome!Was it usefull?  :)

well, it was useful in a way-- it didn't solve my actual problem but your way of "Response.Write" is much better cause it enables me to separate those records (nick, comment and time) so I can modify their appearance separately..But my actual problem still stands.. I can't add the first comment through my form.. It's the same error again..Can you try to rewrite the code once again?
Link to comment
Share on other sites

.. I can't add the first comment through my form.. It's the same error again..

I don't get the problem... Did you try the loop I gave you, what error do you get?
Can you try to rewrite the code once again?

:) No, this time we will do it together, otherwise I feel you won't understand what you do.
Link to comment
Share on other sites

I don't get the problem... Did you try the loop I gave you, what error do you get?:)  No, this time we will do it together, otherwise I feel you won't understand what you do.

I tried to use the loop you gave me:<%'...Do While Not rs.EOF And Not rs.BOF Response.Write(rs("ime") & " " & rs("komentar") & " " & rs("vrijeme"))rs.MoveNextLoop'... %>..but it just doesn't seem to work..Regarding the error i get, it's the same one I've been getting before: sth like this: YOUR SESSION HAS EXPIRED, remember?The code I need is the one that will enable me to show comments with certain ID AND if THERE IS NO RECORD with that ID, the code should enable me to add THE FIRST ONE using the form provided.So, the problem is users can't add any comments unless there is AT LEAST ONE with that ID.Since your previous loop doesn't work (whole system slows down and nothing happens for some time and then the error appears), maybe you can come up with something else?Thanks Jerome..
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...