|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi, i'm completely stumped with this one. It is a simple test (via IF) for booking where it decides which path to follow. Or not so simple, even.. It keeps taking me to same bit. Have tried putting form value into variable. Tried rearranging various ways. The available is definatley being calculated properly and have it displayed. What can be going wrong with form? (just added 'id' there too)
Is there something missing or do i have to convert to integer format or something? The two "booked" and "places" fields are long integers, no indexing, not autoincrements or anything. Have tried for ages with this and is holding me back from the rest of code and final few pages of my site...which is VERY frustrating. Any help would be more than great, andy <% 'Set the server locale Session.LCID = 2057 %> <html> <body> <h2>booking of course continued...</h2> <% dim cid, sid, available, placeswanted, newBooked, newPlaces cid=Request.Cookies("currentuserID") sid=Request.Cookies("scheduleIDbooking") Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & _ Server.MapPath("DATABASE.mdb") set rs = Server.CreateObject("ADODB.Connection") sql = "SELECT * FROM SCHEDULE" sql = sql & " WHERE Schedule.ScheduleID =" & sid & "; " set rs = Conn.Execute(sql) available =rs("Places")-rs("Booked") if Request.Form("PlacesWanted") > available then %> Sorry there are not enough places currently left for this booking. we have <%=available %> places left. <p>cid = <%=cid %></p> <p>sid = <%=sid %> </p> <br />Try again or follow links below: <form method="post" action="processBookPlaces.asp"> required places:<input type="text" name="PlacesWanted"> <input type="submit" value="book"> </form> <a href="searchDropDown.asp">back</a> <a href="home.asp">home</a> <%else newBooked = RS("Booked") + Request.Form("PlacesWanted") newPlaces = RS("Places") - Request.Form("Places") %> <P>NEWBOOKED= <%=newBooked %> <p>newPlaces= <%=newPlaces %> <% if err<>0 then response.write("No update permissions!") response.write "VBScript Errors Occured:" & "<P>" response.write "Error Number=" & err.number & "<P>" response.write "Error Descr.=" & err.description & "<P>" response.write "Help Context=" & err.helpcontext & "<P>" response.write "Help Path=" & err.helppath & "<P>" response.write "Native Error=" & err.nativeerror & "<P>" response.write "Source=" & err.source & "<P>" response.write "SQLState=" & err.sqlstate & "<P>" else response.write("Record " & sid & " was booked!") %> BLAHHHHHHH.... <% end if end if %> </body> </html> |
|
#2
|
||||
|
||||
|
try this
Code:
available = CInt(rs("Places") - rs("Booked"))
if CInt(Request.Form("PlacesWanted")) > available then
|
|
#3
|
|||
|
|||
|
THANKYOU!!
I couldn't have slept if that wasn't working, cheers, andy |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > help with variable problem in IF statement? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|