shill Posted April 4, 2006 Share Posted April 4, 2006 Greetings. I’m trying to send data to mySql for a band touring schedule. Everything is working fine except I cant format the date (000-00-00) or get the date to mySql. I would be grateful for any help.Thanks[code]<?php // Script 12.5 - add_entry.php ini_set ('display_errors', 1);error_reporting (E_ALL & ~E_NOTICE);if (isset ($_POST['submit'])) { // Handle the form. if ($dbc = @mysql_connect ('localhost', 'root', 'password')) { if (!@mysql_select_db ('tourdates')) { die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>'); } } else { die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>'); } $query = "INSERT INTO show_dates ( show_id, show_date, show_city, show_state, show_country, show_venue, show_comments, date_entered) VALUES (0, '{$_POST['date']}', '{$_POST['city']}', '{$_POST['state']}', '{$_POST['country']}', '{$_POST['venue']}', '{$_POST['comments']}', NOW())"; if (@mysql_query ($query)) { print '<p>The show date has been added.</p>'; } else { print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } mysql_close();} ?><form action="add_date.php" method="post"><p> <label>Month <select name="month"> <option value="01" selected="selected">1</option> <option value="02">2</option> <option value="03">3</option> <option value="04">4</option> <option value="05">5</option> <option value="06">6</option> <option value="07">7</option> <option value="08">8</option> <option value="09">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> Day <select name="day"> <option value="01" selected="selected">1</option> <option value="02">2</option> <option value="03">3</option> <option value="04">4</option> <option value="05">5</option> <option value="05">6</option> <option value="07">7</option> <option value="08">8</option> <option value="09">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> </label> <label></label> <label>Year <select name="year"> <option value="2006" selected="selected">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> </select></label></p><!--<p>Show Date : <input type="text" name="date" size="40" maxsize="100" /></p> --><p>Show City : <input type="text" name="city" size="40" maxsize="100" /></p><p>Show State : <input type="text" name="state" size="40" maxsize="100" /></p><p>Show Country : <input type="text" name="country" size="40" maxsize="100" /></p><p>Show Venue : <input type="text" name="venue" size="40" maxsize="100" /></p><p>Show Comments: <textarea name="comments" columns="40" rows="5"></textarea></p><input type="submit" name="submit" value="Add this show date" /></form>[/code] Quote Link to comment Share on other sites More sharing options...
Guest footballkid4 Posted April 4, 2006 Share Posted April 4, 2006 Have a look at strtotime(), that should convert your inputted form data to a PHP timestamp, which can easily be stored in a MySQL database. Quote Link to comment 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.