Jump to content

Help with "int" in mysql...


Orate!

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/2640-help-with-int-in-mysql/
Share on other sites

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.

304569[/snapback]

 

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

Link to comment
https://forums.phpfreaks.com/topic/2640-help-with-int-in-mysql/#findComment-8757
Share on other sites

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?

305009[/snapback]

 

 

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)

Link to comment
https://forums.phpfreaks.com/topic/2640-help-with-int-in-mysql/#findComment-8817
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.