Originally posted by devinemke
you are trying to insert 6 fields into a table that only has 5 (according to your "create table" SQL). there is no "closed" field into your table.
Sorry, that was a mistype on my behalf. I was in a hurry when posting this and typed "closed" twice for some reason. What Really is going on is this:
CREATE TABLE Tasks (post_date DOUBLE NOT NULL, close_date DOUBLE NOT NULL, last_edit DOUBLE NOT NULL, subject CHAR(254) NOT NULL, body BLOB NOT NULL);
INSERT INTO Tasks(post_date, closed_date, last_edit, subject, body) VALUES($currdate, $closed_date, $currdate, '{$taskarr['subject']}', '{$taskarr['body']}')
After it's parsed by PHP, it is:
INSERT INTO Tasks(post_date, closed_date, last_edit, closed, subject, body) VALUES(1090772574, 0, 1090772574, 0, 'Blah', 'Blah');
So, I'm not really doing the 6 elements in my code... I just mistyped that on this forum.
Any other ideas?
Here is the function:
function postNewTask($taskarr)
{
$conn = mysql_connect("localhost", "organizer", "organizer");
mysql_select_db("Organizer");
$currdate = time();
if ($taskarr['closed'] != "")
{
$taskarr['closed'] = 1;
$closed_date = $currdate;
}
else
{
$taskarr['closed'] = 0;
$closed_date = 0;
}
/* insert into database. */
$q = "INSERT INTO Tasks(post_date, closed_date, last_edit, subject, body)" .
" VALUES($currdate, $closed_date, $currdate, " .
" '{$taskarr['subject']}', '{$taskarr['body']}');";
echo "$q<BR><BR>";
mysql_query($q);
mysql_close($conn);
}
It's called like this:
postNewTask($_POST);