Forum Moderators: coopster

Message Too Old, No Replies

Incorrect date value: '' for column 'dateStop' at row 1

         

shams

1:37 am on Jul 8, 2006 (gmt 0)

10+ Year Member



hi,
i installed mysql-5.0.21-win32 and php-5.1.4-Win32.zip in windows xp, created table with:
$query = "CREATE TABLE register (id MEDIUMINT NOT NULL AUTO_INCREMENT,dateReg DATE,name VARCHAR(100),fatherN VARCHAR(100),sex VARCHAR(10),age int,address VARCHAR(256),phone VARCHAR(15),dateAttStar DATE,attCat VARCHAR(30),diseaseClass VARCHAR(10),site VARCHAR(30),type VARCHAR(50),weight0 INT,sp0 VARCHAR(20),sp0Date DATE,sp0Lab int,cs1 VARCHAR(30),dateStop DATE,patientIs VARCHAR(30),remarks VARCHAR(256),PRIMARY KEY (id))";
The table was created successfully, now want to insert the valuse into table, this is the a portion of form for entering values:
<form action="insertedReg2.php" method="post">
<b>
Date Of Registration:<input type="text" name="dateReg"><br>
Name: <input type="text" name="name"><br>
Father Name: <input type="text" name="fatherN"><br>
some more and final lines are:First C/S Sensitive Drugs: <input type="text" name="cs1"><br>
Date ATT Stopped: <input type="text" name="dateStop"><br>
Patient IS: <input type="text" name="patientIs"><br>
Remarks: <input type="text" name="remarks"><br>
and this is the php code to insert the values in the table:

$dateReg = $_POST['dateReg'];
$name = $_POST['name'];
$fatherN = $_POST['fatherN'];
$sex = $_POST['sex'];
$age = $_POST['age'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$dateAttStar = $_POST['dateAttStar'];
$attCat = $_POST['attCat'];
$diseaseClass = $_POST['diseaseClass'];
$site = $_POST['site'];
$type = $_POST['type'];
$weight0 = $_POST['weight0'];
$sp0 = $_POST['sp0'];
$sp0Date = $_POST['sp0Date'];
$sp0Lab = $_POST['sp0Lab'];
$cs1 = $_POST['cs1'];
$dateStop = $_POST['dateStop'];
$patientIs = $_POST['patientIs'];
$remarks = $_POST['remarks'];

mysql_connect("localhost", "root") or die(mysql_error());
mysql_select_db("mydb") or die(mysql_error());

$query = "INSERT INTO register (dateReg,name,fatherN,sex,age,address,phone,dateAttStar,attCat,diseaseClass,site,type,weight0,sp0,sp0Date,sp0Lab,cs1,dateStop,patientIs,remarks) values ('$dateReg', '$name', '$fatherN', '$sex', '$age', '$address', '$phone', '$dateAttStar', '$attCat', '$diseaseClass', '$site', '$type', '$weight0', '$sp0', '$sp0Date', '$sp0Lab', '$cs1', '$dateStop', '$patientIs', '$remarks')";
but the error is:
Incorrect date value: '' for column 'dateStop' at row 1
i tried the empty value then 0000-00-00 and finally 2006-07-02 for the dateStop but with all i get the above error, when i insert the values into table directly from the mysql window the above isnert syntax is working without any error, any one can help please?

[edited by: jatar_k at 12:43 am (utc) on July 17, 2006]
[edit reason]
[1][edit reason] fixed sidescroll [/edit]
[/edit][/1]

dreamcatcher

6:29 am on Jul 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looks like this has everyone stumped shams. Your syntax looks fine, so its hard to see why the query is failing.

Did you have any joy sorting this out?

dc

eelixduppy

11:48 pm on Jul 16, 2006 (gmt 0)



Have you tried echoing the query to the browser. You may be able to identify any problems with your query this way. Also, here is information about DATE [dev.mysql.com] types.

Good luck!