Jump to content

sum integers


vadder85

Recommended Posts

hellohope anyone can help mebelow are my coding<%meal = request("meal")acm = request("accomodation")total_cost = meal + acm%>let say meal = 1 and acm = 1suppose the answer will be 2 rite after we add both integers BUT what i got isoutput = 11so how to solve this problem?any one know?tq..

Link to comment
Share on other sites

When you retrieve values from the query string they are stored as a sting, that is why you get 11 - it's a string not a number. What you have to do is convert them back to a number before use, use the built in function cint()meal = cint(request("meal"))acm = cint(request("accomodation"))total_cost = meal + acmI've not tested it but im sure it's correct :)

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
×
×
  • Create New...