Orate! Posted October 9, 2005 Share Posted October 9, 2005 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. Quote Link to comment https://forums.phpfreaks.com/topic/2640-help-with-int-in-mysql/ Share on other sites More sharing options...
ryanlwh Posted October 9, 2005 Share Posted October 9, 2005 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. Quote Link to comment https://forums.phpfreaks.com/topic/2640-help-with-int-in-mysql/#findComment-8754 Share on other sites More sharing options...
Orate! Posted October 10, 2005 Author Share Posted October 10, 2005 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? Quote Link to comment https://forums.phpfreaks.com/topic/2640-help-with-int-in-mysql/#findComment-8757 Share on other sites More sharing options...
ryanlwh Posted October 11, 2005 Share Posted October 11, 2005 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? Quote Link to comment https://forums.phpfreaks.com/topic/2640-help-with-int-in-mysql/#findComment-8773 Share on other sites More sharing options...
Orate! Posted October 13, 2005 Author Share Posted October 13, 2005 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) Quote Link to comment https://forums.phpfreaks.com/topic/2640-help-with-int-in-mysql/#findComment-8817 Share on other sites More sharing options...
ryanlwh Posted October 13, 2005 Share Posted October 13, 2005 you wrote your own function to average the numbers? Quote Link to comment https://forums.phpfreaks.com/topic/2640-help-with-int-in-mysql/#findComment-8818 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.