prichardson Posted June 21, 2007 Share Posted June 21, 2007 I am trying to get when someone adds a new rating for a video that it adds to the database. The problem it does not "add" when the video being rated the second time . I.e. If the video the first time was rated 5 and on the second time it is rated also 5 it should be 10 but it ends up as 55. Can anyone see the problem in my code? <%dim strTotalVotersdim strTotalScore strTotalVoters = (rsDisplayVideo.Fields.Item("Video_Rating_Total_Voters").Value)strTotalScore = (rsDisplayVideo.Fields.Item("Video_Rating_Total_Score").Value)%><% If request.Form("action") = "rate" thendim strRequestTotalScore dim strRequestTotalVotersFinaldim strRequestTotalScoreFinal dim strVideo_IDstrVideo_ID = (Request.Form("VideoID"))strRequestTotalScore = CINT(Request.Form("Video_Rating_Total_Score"))strRequestTotalVotersFinal = strTotalVoters+1strRequestTotalScoreFinal = strRequestTotalScore + strTotalScorestrUpdateSQL = strDBDateFormat & "UPDATE NNS_Video SET "strUpdateSQL = strUpdateSQL & "Video_Rating_Total_Score = " & strRequestTotalScore & request.Form("rRate") & ", "strUpdateSQL = strUpdateSQL & "Video_Rating_Total_Voters = " & strRequestTotalVotersFinal & " "strUpdateSQL = strUpdateSQL & "WHERE VideoID=" & strVideo_ID & ""Call subUpdateRecord(strUpdateSQL)Response.Redirect("../member/member_search_results.asp")End If%> Link to comment Share on other sites More sharing options...
justsomeguy Posted June 21, 2007 Share Posted June 21, 2007 You're working with strings instead of numbers. Cast the strings as integers and it will work. Link to comment Share on other sites More sharing options...
prichardson Posted June 22, 2007 Author Share Posted June 22, 2007 Like this: strRequestTotalScoreFinal = cint(strRequestTotalScore) + cint(strTotalScore) ??I have tried this but it still seems to put the total score: 5+5 as 55 rather than 10!Is the rest of the code i put in my first post coorect? Should i make the strings integers before this line? Please tell me if the code above should work and if not- what code would make it work?Many thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted June 25, 2007 Share Posted June 25, 2007 Do it as early as necessary. If the values are getting concatenated then they are being treated as strings, so cast them to integers as soon as you need to. You can also add 0 to something to cast the value to an integer. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.