Welcome Guest, Not a member yet? Register   Sign In
Blank fields submitted to DB as zeros
#1

[eluser]heaversm[/eluser]
Hi - just wanted to know how I prevent this - I have a number of non-required multiselect boxes and, if the user selects nothing, the data gets sent to the DB as a "0". How do I prevent this?

The DB is mySQL and the type is tinytext. The default value is set as "NONE"
#2

[eluser]Bart v B[/eluser]
You can start to modify youre mysql database to tell him that you want to have everything in stric_mode.

Code:
# first we check wich mode..
SELECT @@session.sql_mode;

# change the mode..
SET SESSION sql_mode = 'TRADITIONAL,ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO';

#now we see the new mode..
SELECT @@session.sql_mode;

EDIT if you want to have this mode, you need to modify your my.ini.
First turn mysql off.

Then seach in your my.ini this line:
sql_mode =

Change that to:
sql_mode = TRADITIONAL,ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO

Start the mysql server again.
Now it's alway's the right setting Smile




Theme © iAndrew 2016 - Forum software by © MyBB