russia5
06-01-2008, 09:13 PM
I have a form that posts the narrative of a month, ie) January and inserts it into a MySQL field, age_mth (it works fine) I want to also insert the numerical value of the month into another MySQL field age_month ie) 01 should go into age_month - this does not work and I need to figure out what I am doing wrong.
I have created a file called month_conversion.php that has a lookup table that converts the narrative to the month.
<?php
SMARTY INCLUDES GO HERE
$lookup = array("January" => 01, "February" => 02, "March" => 03. "April" => 04, "May" => 05, "June" => 06, "July" => 07, "August" => 08, "September" => 09, "October" => 10, "NOvember" => 11, "December" => 12);
// use month names on your form
$month = $_POST["age_month"]; // the name
$monthnum = $lookup[$month]; // the number
$query = 'INSERT INTO subdomain_submission (age_month) VALUES ('$monthnum')';
?>
the database table is subdomain_submission and the database field is age_month. The SMARTY includes are standard on my site and connect to the database for the other applications.
Upon submission, I get a 0 put into age_month no matter what month I have selected. Can someone see what I am doing wrong?
I have created a file called month_conversion.php that has a lookup table that converts the narrative to the month.
<?php
SMARTY INCLUDES GO HERE
$lookup = array("January" => 01, "February" => 02, "March" => 03. "April" => 04, "May" => 05, "June" => 06, "July" => 07, "August" => 08, "September" => 09, "October" => 10, "NOvember" => 11, "December" => 12);
// use month names on your form
$month = $_POST["age_month"]; // the name
$monthnum = $lookup[$month]; // the number
$query = 'INSERT INTO subdomain_submission (age_month) VALUES ('$monthnum')';
?>
the database table is subdomain_submission and the database field is age_month. The SMARTY includes are standard on my site and connect to the database for the other applications.
Upon submission, I get a 0 put into age_month no matter what month I have selected. Can someone see what I am doing wrong?