Forum Moderators: coopster

Message Too Old, No Replies

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

mysql php insert error

         

shams

4:03 pm on Jul 2, 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) NOT NULL,fatherN VARCHAR(100) NOT NULL,sex VARCHAR(10) NOT NULL,age int NOT NULL,address VARCHAR(256) NOT NULL,phone VARCHAR(15),dateAttStar DATE,attCat VARCHAR(30) NOT NULL,diseaseClass VARCHAR(10) NOT NULL,site VARCHAR(30),type VARCHAR(50) NOT NULL,weight0 INT NOT NULL,sp0 VARCHAR(20) NOT NULL,sp0Date DATE,sp0Lab int(5) NOT NULL,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 with this php code:

$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'];

$query = "INSERT INTO register SET dateReg='$dateReg', name='$name', fatherN='$fatherN', sex='$sex', age='$age', address='$address', phone='$phone', dateAttStar='$dateAttStar', attCat='$attCat', diseaseClass='$diseaseClass', site='$site', type='$type', weight0='$weight0', sp0='$sp0', sp0Date='$sp0Date', sp0Lab='$sp0Lab', cs1='$cs1', dateStop='$dateStop', patientIs='$patientIs', remarks='$remarks'";

but the error is:
Incorrect date value: '' for column 'dateReg' at row 1

the date value i am inserting is 2006-02-01 which is the correct date format for mysql, any one can help please?

[edited by: jatar_k at 6:30 pm (utc) on July 2, 2006]
[edit reason] fixed sidescroll [/edit]

the_nerd

7:30 pm on Jul 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



did you try and "echo" the content of $query and paste it into a PhpMyAdmin Window? This way you see what really comes out of your form, and you get the real Error Message.

btw. never saw the insert syntax you used .. wouldn't you usually use

INSERT INTO mytab (field1, field2,....) VALUES ('val1', 'val2', ...)?

I tried yours and it worked, but it looks like a mixture of INSERT and UPDATE?