Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Post in forum, from outside forum.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Post in forum, from outside forum.

 Post Reply Post Reply
Author
BrownGhost View Drop Down
Groupie
Groupie


Joined: 26 November 2002
Status: Offline
Points: 193
Post Options Post Options   Thanks (0) Thanks(0)   Quote BrownGhost Quote  Post ReplyReply Direct Link To This Post Topic: Post in forum, from outside forum.
    Posted: 20 June 2006 at 10:19pm

Post in forum, from outside forum.

 

We have made a function in version 7.1 where visitors could comment news written on my page.

When selecting to comment a post was made in forum, in a category we already have decided what was. And it would post as the news writer as we include his id and stuff.

All working great.

 

Now after we have updated to V 8.2 this function still works, except, the post don’t show op in the forum, if you select that category. If I track the post via ID I can see its there. But its not showing up in forum. I know what the problem is, but don’t how to fix it.

 

The problem was when we make a post in forum via our news page it did not create: Start_Thread_ID Last_Thread_ID

 

So I try the code below to fix that problem.

Works until some one deletes a post, then its not right any more.

 

Lets say Thread_ID 12 was deleted.

Then next Thread_ID will be 13
But my code will look in forum see that 11 is there + 1 and assume its 12.

And use 12 for my post :(

 

 

 

            strSQL = "SELECT Max(Thread_ID+1) AS ID FROM tblThread"

            lngThreadID = objConn.Execute(strSQL)("ID")

           

           

            strSQL = _

                        "INSERT INTO tblTopic(Forum_ID,Poll_ID,Moved_ID,Subject,Start_Date,Last_Entry_Date,No_Of_Views,Locked,Priority,NewsID,Start_Thread_ID,Last_Thread_ID) " & _

                        "VALUES("& intForumID &",0,0,'" & strTitleName & "',GetDate(),GetDate(),0,0,0," & lngNewsID & "," & lngThreadID & "," & lngThreadID & ")"

            objConn.Execute strSQL

           

           

            strSQL = "SELECT Max(Topic_ID) AS ID FROM tblTopic"

            lngTopicID = objConn.Execute(strSQL)("ID")

           

            strSQL = _

                        "INSERT INTO tblThread(Topic_ID,Author_ID,Message,Message_Date,Show_Signature,IP_Addr) " & _

                        "VALUES(" & lngTopicID & "," & strTeamUserID & ",'" & strTeaser & "',GetDate(),0,'')"

            objConn.Execute strSQL

 

 

Can you think of a way i can fix this problem?

Thanks a lot.

Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 21 June 2006 at 10:24am
Have a look in the files new_post.asp, and delete_post.asp handle the insert and deletion of posts. This should give you some idea of what to do.
Back to Top
BrownGhost View Drop Down
Groupie
Groupie


Joined: 26 November 2002
Status: Offline
Points: 193
Post Options Post Options   Thanks (0) Thanks(0)   Quote BrownGhost Quote  Post ReplyReply Direct Link To This Post Posted: 21 June 2006 at 6:30pm
Humm that gave me an idear for, changing my code at bit. its now working..

strSQL = _
        "INSERT INTO tblTopic(Forum_ID,Poll_ID,Moved_ID,Subject,Start_Date,Last_Entry_Date,No_Of_Views,Locked,Priority,NewsID) " & _
        "VALUES("& intForumID &",0,0,'" & strTitleName & "',GetDate(),GetDate(),0,0,0," & lngNewsID & ")"
    objConn.Execute strSQL
   
   
    strSQL = "SELECT Max(Topic_ID) AS ID FROM tblTopic"
    lngTopicID = objConn.Execute(strSQL)("ID")
   
    strSQL = _
        "INSERT INTO tblThread(Topic_ID,Author_ID,Message,Message_Date,Show_Signature,IP_Addr) " & _
        "VALUES(" & lngTopicID & "," & strTeamUserID & ",'" & strTeaser & "',GetDate(),0,'')"
    objConn.Execute strSQL
Else
    lngTopicID = rsTopic("Topic_ID")
End If

   
    strSQL = "SELECT Max(Thread_ID) AS ID FROM tblThread"
    lngThreadID = objConn.Execute(strSQL)("ID")


strSQL = "UPDATE tblTopic SET Start_Thread_ID=" & lngThreadID & ", Last_Thread_ID=" & lngThreadID & " WHERE Topic_ID=" & lngTopicID
        objConn.Execute strSQL

Response.Redirect "/forum/forum_posts.asp?TID=" & lngTopicID


Now i set the Start_Thread_ID and Last_Thread_ID at the end of my code.
But Qcustion is, what if some other user makes new thred at the same time ??

Can i Lock the tabel until im don running my code..
And how do one do this?

Thx
im not proff programmer as you, so i need some help.
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 21 June 2006 at 7:18pm
It should be fine how it is.

If by some 1 million to 1 chance another user posted at the same time as you and the database updated their stats in a million second before yours then you would just have the wrong poster displayed as the last poster in that topic, this will be updated when a new user posts or you use the admin button to update the topic.

By the way for performance reasons the database isn't locked during this process in version 8 anyway.

Most 'updates' are now row locks, and most 'reads' are now 'dirty' reads were the database is not locked during the read. This hasn't seemed to create a problem, but does increase performance.


Edited by -boRg- - 21 June 2006 at 7:20pm
Back to Top
BrownGhost View Drop Down
Groupie
Groupie


Joined: 26 November 2002
Status: Offline
Points: 193
Post Options Post Options   Thanks (0) Thanks(0)   Quote BrownGhost Quote  Post ReplyReply Direct Link To This Post Posted: 21 June 2006 at 7:37pm
okay then its not realy a problem. all is good, and i want to thank you for all your help.. :)

Making a new site for a costumer of mine thy want forum also, so im buying more forum later this week :)

thanks...
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 22 June 2006 at 10:18am
Cool 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.