smitagodbole Posted September 26, 2010 Share Posted September 26, 2010 Hi I don't know exactly what to do to see correct date of birth into my sql database. I have following code i.e. $month=$_POST['month']; $year=$_POST['year']; $date=$_POST['date']; $date_value="$month/$date/$year"; echo"YYYY-mm-dd format:$date_value"; and sql insert statement is like this $sql = "INSERT INTO table_name(fname, lname, gender, add1, add2, city, state, zip, country, email, phone, cellphone, dob, photo1) VALUES('$fname','$lname','$gender','$add1','$add2','$city','$state','$zip','$country','$email','$phone','$cellphone', '$date_value','" . $image['name'] . "')"; I don't know what exactly I need to do? Even though I changed the setting in php ini to register_globals = On I would appreciate any kind of help regarding this matter. Thanks Smita Quote Link to comment https://forums.phpfreaks.com/topic/214483-my-php-script-saves-date-0000-00-00-into-mysql-database/ Share on other sites More sharing options...
Pikachu2000 Posted September 26, 2010 Share Posted September 26, 2010 First, go back and change register_globals back to off. It has nothing to do with this problem. Then, post the html for the form fields that collect the information for the date. Quote Link to comment https://forums.phpfreaks.com/topic/214483-my-php-script-saves-date-0000-00-00-into-mysql-database/#findComment-1116097 Share on other sites More sharing options...
PFMaBiSmAd Posted September 26, 2010 Share Posted September 26, 2010 I changed the setting in php ini to register_globals = On ^^^ Why on earth did you do that. That setting has absolutely nothing to do with the format of your date, especially since you echo the date you build and it is probably what you expect (though it is not what mysql expects.) Mysql date data types are formatted YYYY-MM-DD. Don't you suppose that you would need to get your date value into that format in order to be able to store it without error? Quote Link to comment https://forums.phpfreaks.com/topic/214483-my-php-script-saves-date-0000-00-00-into-mysql-database/#findComment-1116098 Share on other sites More sharing options...
smitagodbole Posted September 28, 2010 Author Share Posted September 28, 2010 Here is my html script and I did change my insert script to $date_value="$year/$month/$dt"; <select name="year" ></th> <option>Year</option> <option>1970</option><option>1971</option><option>1972</option><option>1973</option><option>1974</option><option>1975</option><option>1976</option><option>1977</option><option>1978</option><option>1979</option><option>1980</option><option>1981</option><option>1982</option><option>1983</option><option>1984</option><option>1985</option><option>1986</option><option>1987</option><option>1988</option><option>1989</option><option>1990</option><option>1991</option><option>1992</option> </select> <select size="1" name="month"></th> <option>select month</option> <option>January</option><option>February</option><option>March</option><option>April</option><option>May</option><option>June</option><option>July</option><option>August</option><option>September</option><option>October</option><option>November</option><option>December</option> <option value='01'>January</option><option value='02'>February</option><option value='03'>March</option><option value='04'>April</option><option value='05'>May</option><option value='06'>June</option><option value='07'>July</option><option value='08'>August</option><option value='09'>September</option><option value='10'>October</option><option value='11'>November</option><option value='12'>December</option> </select> <select size="1" name="date" ></th> <option>Date</option> <option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option><option>24</option><option">25</option><option>26</option><option>27</option><option>28</option><option>29</option><option>30</option><option>31</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/214483-my-php-script-saves-date-0000-00-00-into-mysql-database/#findComment-1116546 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.