Jump to content

Not inserting date


Xtremer360

Recommended Posts

The file works fine mostly. Problem is when I open the javascript calender script and choose a date it puts it into the text field as ????-??-?? which is fine however I have I have the bookingdate field in my database as a date field type and don't know why it's not putting in the bookingdate into the query.

 

<?php 
    $e = <<<here
<script type="text/javascript" src="./jscripts/ajax.js"></script>                
<script type="text/javascript" src="./jscripts/ts_picker.js"></script>                
here;
    switch ($_REQUEST['option']) {
        case 0:
            echo $e;
            ?>
            <h1 class=backstage>Show Booking Management</h1><br />
            <form name="eventbooker" method="post">
            <input type="hidden" name="action" value="eventbooker" />    
            <table width="100%" class="table2">
                <tr>
                    <td width="150" valign="center" class="rowheading">Show Name:</td>
                    <td class="row3">
                    <select name="event" class="dropdown">
                    <option value="Null">- Select -</option>
                    <?php
                    $query = "SELECT * FROM efed_list_shownames";
                    $result = mysql_query ( $query );
                    while ( $row = mysql_fetch_assoc ( $result ) )
                    {
                        print "<option value=\"".$row['id']."\">".$row['name']."</option>\r";
                    }
                    ?>
                    </select></td>
                    <td class="row3" width="180"><span class="reduced">Set up in show Name Manager</span></td>
                </tr>
                <tr>
                    <td width="150" valign="center" class="rowheading">Air Date</td>
                    <td class="row3"><input type="text" name="bookingdate" class="fieldtext80" value=""><a href="javascript:show_calendar(document.eventbooker.bookingdate, document.eventbooker.bookingdate.value);"><img src="http://www.defiantwrestling.net/backstage/images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick the date"></a></td>
                    <td class="row3"><span class="reduced">dd-mm-yyyy</span></td>
                </tr>
                <tr>
                    <td class="rowheading" width="150" valign="center" class="rowheading">No. of Matches:</td>
                    <td class="row3"><input type="text" name="numberofmatches" class="fieldtext40"></td>
                    <td class="row3"><span class="reduced">More can be added later</span></td>
                </tr>
                <tr>
                    <td class="rowheading">Country</td>
                    <td class="row3" colspan="2">
                    <select name="countryid" class="dropdown" onchange="ajaxpage('backstageajax.php?random=625094862&routine=arenas&countryid='+this.value,'arenaajax');">
                    <option value=0>- Select -</option>
                    <?php
                    $query = 'SELECT * FROM efed_list_arenas_countries';
                    $result = mysql_query ( $query );
                    while ( $row = mysql_fetch_assoc ( $result ) )
                    {
                        print "<option value=\"".$row['id']."\">".$row['country']."</option>\r";
                    }
                    ?>
                    </select></td>
                </tr>
                <tr>
                    <td class="rowheading">Arena</td>
                    <td class="row3" colspan="2"><div id="arenaajax">
                    <select name="arenaid" class="dropdown">
                    <option value="0">- Select Arena -</select>
                    </div></td>
                </tr>
            </table><br />
            <input type="hidden" name="newadded" value="true"> 
            <input type="submit" value="Add Booking" class="button"></form><br />
            <input type="button" value="Return to Booking Manager" class="button200"><br /><br />
           <?php
            returnmain();
        break;
    }
    function eventbooker() {
        if ((!empty($_POST['newadded']))) {
            $event = mysql_real_escape_string($_POST['event']);
            $bookingdate = mysql_real_escape_string($_POST['bookingdate']);
            list($day, $month, $year) = explode("-", $_POST['bookingdate']);
            $bookingdate = sprintf('%d-%d-%d', $year, $month, $day);  
            $numberofmatches = mysql_real_escape_string($_POST['numberofmatches']);
            $arenaid = mysql_real_escape_string($_POST['arenaid']);
            $query = "INSERT INTO `efed_content_booking` (event_id,status_id,bookingdate,arena_id,matches) VALUES ('".$event."', 1, '".$bookingdate."', '".$arenaid."', '".$numberofmatches."')";
            mysql_query($query);
        }
    }
?> 

Link to comment
https://forums.phpfreaks.com/topic/195632-not-inserting-date/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.