1

I have a custom table with column 'discount_percentage', which is a signed integer.

e.g. +5 , -2 likewise

I have defined the data type as Varchar for this field. But it's not saving the value properly. When I save +10 it will only save 10. But I want it to be as +10.

I tried by enclosing the single quotes. But didn't work.

Please can anyone explain what am I missing here?

  • What is the input validation set to? – Melvyn Dec 15 '14 at 17:56
  • No validation has been set – Sukeshini Dec 15 '14 at 18:06
  • Not sure about the cause without seeing the attribute dump, but since this is at max 200 values, you could implement this as dropdown. So single select for the input. – Melvyn Dec 15 '14 at 18:10
  • Anyway I was able to save minus values (e.g. -4 ) in database under the type of VARCHAR. But strings like +3, +4 still cannot save – Sukeshini Dec 17 '14 at 15:21
  • Check what the default input validation is and check for proper encoding of the value. A plus can be interpreted as space. However, if you can save negative values and the value is not zero, then it's positive, so the problem can be worked around. – Melvyn Dec 17 '14 at 17:14
0

I guess that javascript verification input has absolute value numeric transformation, or use to save as (string)$discount_percentage in php

  • Tried. This doesn't work – Sukeshini Dec 15 '14 at 18:07
  • variable is from url ? , check if utf-8 table format, and variable php, or check if has white spaces – Adrian R Dec 15 '14 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.