Hope that Subject describes my problem well enough...
Anyway...
I have a form, about 5 fields are required and the rest could be null inserted into database. If a user fills out every field on the form, it inserts into the MySQL database perfectly, all data is retrievable. BUT, if they left even one (non-required) field blank, I would get a MySQL error... something like this:
INSERT INTO tblNetDesc (SubSample, StretchMeshSize, Twist, NumStrands, Floats, Rope, Weight, RopeDiam1, RopeLngth1min, RopeLngth1max, RopeDiam2, RopeLngth2min, RopeLngth2max, RopeDiam3, RopeLngth3min, RopeLngth3max, TrimmedEdge, Foul, BreaksEasily, Initial, InitialDate, NetClassID, ConstructionID, ColorID, NetTypeID, TrimColorID, PictureName, Comment, TwineDiam) VALUES ('A', , '', , '', '', , , , , , , , , , , '', , '', '', , 12, , , 2, , '', '', )You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' '', , '', '', , , , , , , , , , , '', , '', '',
Is there a reason why MySQL can not tell that a blank should be stored as a NULL automatically in MySQL? BTW, this is the 2nd query of a multiple insert, the first went through fine, in this query, only the 12 (which is the ID of the first insert) and 'A' is required in the database. One other thing is that all fields except the ones that are required has been set DEFAULT NULL in MySQL.
Does anyone know what the like problem is? I'm not thinking I need to check every field to see if it isempty() and setting it to NULL and sending NULL to the database rather than a blank.
Thanks for looking at my issue...
-T
Anyway...
I have a form, about 5 fields are required and the rest could be null inserted into database. If a user fills out every field on the form, it inserts into the MySQL database perfectly, all data is retrievable. BUT, if they left even one (non-required) field blank, I would get a MySQL error... something like this:
INSERT INTO tblNetDesc (SubSample, StretchMeshSize, Twist, NumStrands, Floats, Rope, Weight, RopeDiam1, RopeLngth1min, RopeLngth1max, RopeDiam2, RopeLngth2min, RopeLngth2max, RopeDiam3, RopeLngth3min, RopeLngth3max, TrimmedEdge, Foul, BreaksEasily, Initial, InitialDate, NetClassID, ConstructionID, ColorID, NetTypeID, TrimColorID, PictureName, Comment, TwineDiam) VALUES ('A', , '', , '', '', , , , , , , , , , , '', , '', '', , 12, , , 2, , '', '', )You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' '', , '', '', , , , , , , , , , , '', , '', '',
Is there a reason why MySQL can not tell that a blank should be stored as a NULL automatically in MySQL? BTW, this is the 2nd query of a multiple insert, the first went through fine, in this query, only the 12 (which is the ID of the first insert) and 'A' is required in the database. One other thing is that all fields except the ones that are required has been set DEFAULT NULL in MySQL.
Does anyone know what the like problem is? I'm not thinking I need to check every field to see if it isempty() and setting it to NULL and sending NULL to the database rather than a blank.
Thanks for looking at my issue...
-T