Jump to content


Photo

Help with "int" in mysql...


  • Please log in to reply
5 replies to this topic

#1 Orate!

Orate!
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 09 October 2005 - 08:10 PM

Hello there guys, i have a little problem in mysql/php i'm pretty sure someone will be able tu help me ... (I'm a n00b in programming matters at this point, so sorry if its a stupid question)..

I have this form (fig a.) working in a web browser, but when the client leaves the field in blank Mysql stores a "0" (zero) on it, but a need to be (null,1,2,3,4,5,6,7,8,9,10) ONLY, not zero not 15, only the list on (), and obviously is mysql completing the field with zeros, rather than leaving it blank, is there a way to tell that blank is ok in the field?

(fig a.)( <select name="xtag01">
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
)



Thanks guys (sorry for my rusty english)
bye and thanks in advance.


#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 09 October 2005 - 11:48 PM

the problem lies in your form

<option VALUE="1">1</option>

You didn't give the option a value, so it passes a null string.
And by the way, int can never be null... if you need null values, use varchar.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#3 Orate!

Orate!
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 10 October 2005 - 07:10 AM

the problem lies in your form

<option VALUE="1">1</option>

You didn't give the option a value, so it passes a null string.
And by the way, int can never be null... if you need null values, use varchar.

View Post


Ok, ill do that, but a question if I use barchar can i make mathematical operations with the data stored in the fields?

#4 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 11 October 2005 - 12:13 AM

well i think so. never tried that but you can try. but why doesn't 0 work for you? why do you need it to be null for an int anyway?
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#5 Orate!

Orate!
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 October 2005 - 03:47 AM

well i think so. never tried that but you can try. but why doesn't 0 work for you? why do you need it to be null for an int anyway?

View Post



because of the averages...

0 + 10 = 10/2 = 5

NULL + 10 = 10/1 = 10

Zero counts in the averages :(

(sorry for my english is a lot rusty)

#6 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 13 October 2005 - 04:15 AM

you wrote your own function to average the numbers?
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users