Greetings,
This board is great. I've been working to connect flash to my PHP/MySQL site for a while and now I can! I was never aware of the sendAndLoad() functionality of the LoadVars class until I visited here earlier.
So, here's where my problem is coming from. I'm creating an online calendar program for myself. It'll have tasks and events. Tasks have a title, description, due date, and priority. So far, the title, description, and priority are working fine. However, on 7 out of the 9 tests that I made so far, the due date was "lost." It shows on the screen as 0000-00-00 00:00:00 which is the default vaule for the table. However, the two dates that worked are 2001-01-20 01:00:00 and 2002-09-20 04:00:00. The odd part is, that I didn't enter any time into the field, just a date. Plus, it never seems to work for dates in 2004.
Here is the code that is executed when you click the save task button:
on(click) {
new_task = new LoadVars();
new_task.onLoad = function() {
if(this.msg == "saved") _root.status_msg.text = "Task Saved."
else _root.status_msg.text = "Error!!"
}
new_task.title = _parent.i_title.text;
new_task.due_on = _parent.i_due_on.text;
new_task.priority = _parent.i_priority.data[_parent.i_priority.selectedIndex];
new_task.description = _parent.i_description.text;
_parent.i_title.text = "";
_parent.i_due_on.text = "";
_parent.i_priority.selectedIndex = 0;
_parent.i_description.text = "";
new_task.sendAndLoad("
http://www.dashifen.com/calendar/proNewTask.php", new_task, "POST");
}
And here is the code that is at proNewTask.php:
<?
include("functions.php");
include("../db_vars.php");
$title = mysql_escape_string($_POST['title']);
$due_on = $_POST['due_on'];
$priority = $_POST['priority'];
$description = mysql_escape_string($_POST['description']);
$success = runQuery("INSERT INTO cal_data (title, body, start, priority) VALUES ('$title', '$description', '$due_on', $priority)");
if($success) echo "msg=saved&";
else echo "msg=error&";
?>
__________________
the runQuery() function is a self-defined function that uses mysql_connect, mysql_select_db, and mysql_query to execute the sql statement passed to it as the parameter. It has been thouroughly tested and works. The "start" field in the database is used for tasks to represent their due_date. It saved space since I'm using the same table for tasks and events.
So: can anyone figure out with the due_on value isn't always saved? I'm working off the assumption that it's because I've improperly formatted the date in the input field, but I'm not sure which format to use so that the MySQL database will like it.