submitting null value from php to MySql
Hi
I am stumped! My hosting company has a strict policy regarding the DB set up and won't change it as I am on a shared service.
I am retrieving values from a form in php and need to be able to write a null value to some fields, some of the time.
The table is set up to enter null by default for a given row.
CREATE TABLE `content_habitparameters` (
`Content_Habit_ID` int(100) NOT NULL,
`Habit_ID` int(100) NOT NULL,
`Content_ID` int(100) NOT NULL,
`Min_Value` int(10) DEFAULT NULL,
`Max_Value` int(100) DEFAULT NULL,
`yesorno` tinyint(1) DEFAULT NULL,
`Section_Generic` tinyint(4) DEFAULT NULL
PHP Code:
...
...
$minvalue = $_POST['minvalue'];
$maxvalue = $_POST['maxvalue'];
...
...
$insertcontenthabits = "INSERT INTO content_habitparameters (Content_ID, Habit_ID, Min_Value, Max_Value, yesorno, Section_Generic)
VALUES ('" . $contentid . "','" . $habitid . "','" . $minvalue . "','" . $maxvalue . "','" . $boolvalue . "','" . $generic . "')";
This gives me a SQL statement of:
INSERT INTO content_habitparameters (Content_ID, Habit_ID, Min_Value, Max_Value, yesorno, Section_Generic) VALUES ('6','38','','','0','1')
Whilst '' works fine in my dev environment it is no good for my production environment. How do I deal with this?
thanks