jesushax Posted August 22, 2008 Share Posted August 22, 2008 hi below is my add vacancy form heres the debug: INSERT INTO tblVac (VacCat,VacTitle,VacRef,VacTop,VacHrs,VacWage,VacLocation,VacDetails,VacDateAdded,VacArchive) VALUES ('Administration / Clerical', 'test', 'test', '0', 'test', 'test', 'test', 'test ', '2008-22-08','0') yet checking the mysql database i get this (from phpmyadmin) VacID VacCat VacTitle VacRef VacHrs VacLocation VacWage VacDetails VacTop VacDateAdded VacDateModified VacArchive 397 Administration / Clerical test test test test test test<br /> 0 0000-00-00 NULL 0 field type is date, anyone know why? Thanks <?php switch (@$_GET["action"]) { case "add"; include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); $VacCat = $_POST["txtCat"]; $VacTitle = mysql_escape_string($_POST["txtTitle"]); $VacRef = mysql_escape_string($_POST["txtRef"]); if (($_POST["chkTop"]) == "1") { $VacTop = "1"; } else { $VacTop = "0"; } $VacHrs = mysql_escape_string($_POST["txtHrs"]); $VacWage = mysql_escape_string($_POST["txtWage"]); $VacLocation = mysql_escape_string($_POST["txtLocation"]); $VacDetails = mysql_escape_string($_POST["txtDetails"]); $VacAdded = date("Y-d-m"); mysql_query("INSERT INTO tblVac (VacCat,VacTitle,VacRef,VacTop,VacHrs,VacWage,VacLocation,VacDetails,VacDateAdded,VacArchive) VALUES ('$VacCat', '$VacTitle', '$VacRef', '$VacTop', '$VacHrs', '$VacWage', '$VacLocation', '$VacDetails', '$VacAdded','0')") or die (mysql_error()); header("Location: /admin/vacancies/edit_vac_list.php?CAT=$VacCat"); break; default: session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); echo '<div id="subheader"> <div class="padding"> <table width="100%" border="0"> <tr> <td><h2 class="titles">Vacancies</h2> Please feel free to browse and if you have any questions please use our contact form.</td> <td style="text-align:right;"><img src="/images/layout/puddle.png" alt="logo splash" /></td> </tr> </table> </div> </div> <div id="main"> <div class="right_side">'."\n"; ?> <script type="text/javascript"> bkLib.onDomLoaded(function() { new nicEditor({xhtml:true}).panelInstance('txtDetails'); }); </script> <h3 class="titles">Add Vacancy</h3> <form id="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?action=add"> <table width="100%"> <tr> <td>Category: <br /></td> <td> <select name="txtCat" > <option>Administration / Clerical</option> <option>Care / Health</option> <option>Catering</option> <option>Construction</option> <option>Hospitality</option> <option>Professional / Management</option> <option>Retail</option> <option>Security / Ancillary</option> <option>Voluntary</option> </select></td> </tr> <tr> <td>Title: <br /></td> <td> <input type="text" size="50" name="txtTitle" /></td> </tr> <tr> <td>Ref No:</td> <td><input type="text" size="20" name="txtRef" /></td> </tr> <tr> <td>Top:</td> <td><input name="chkTop" type="checkbox" value="1" class="noborder" /></td> </tr> <tr> <td>Hours:</td> <td><input type="text" size="20" name="txtHrs" /></td> </tr> <tr> <td>Wage:</td> <td><input type="text" size="20" name="txtWage" /></td> </tr> <tr> <td>Location:</td> <td><input type="text" size="40" name="txtLocation" /></td> </tr> <tr> <td colspan="2" class="top"> Details: </td> </tr> <tr> <td colspan="2"><textarea name="txtDetails" style="width:550px; height:175px;"></textarea></td> </tr> <tr> <td class="center" colspan="2"> <input type="submit" name="Submit" value="Submit" /> <input type="reset" name="reset" value="reset" /></td> </tr> </table> </form> <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'); break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/120854-solved-dates-not-being-added/ Share on other sites More sharing options...
shotos Posted August 22, 2008 Share Posted August 22, 2008 use a time stamp to store the date. check out this site http://www.tizag.com/phpT/phpdate.php Quote Link to comment https://forums.phpfreaks.com/topic/120854-solved-dates-not-being-added/#findComment-622956 Share on other sites More sharing options...
jesushax Posted August 22, 2008 Author Share Posted August 22, 2008 i do here dont i? $VacAdded = date("Y-d-m"); Quote Link to comment https://forums.phpfreaks.com/topic/120854-solved-dates-not-being-added/#findComment-622961 Share on other sites More sharing options...
kenrbnsn Posted August 22, 2008 Share Posted August 22, 2008 Database dates are in the form of YYYY-MM-DD, not YYYY-DD-MM. Ken Quote Link to comment https://forums.phpfreaks.com/topic/120854-solved-dates-not-being-added/#findComment-622966 Share on other sites More sharing options...
shotos Posted August 22, 2008 Share Posted August 22, 2008 what i meant was that u use the function time() to get the current time stamp for storage in the database. when outputting, the u use getdate() to format it the way u prefer Quote Link to comment https://forums.phpfreaks.com/topic/120854-solved-dates-not-being-added/#findComment-622972 Share on other sites More sharing options...
jesushax Posted August 22, 2008 Author Share Posted August 22, 2008 thanks ken, sorted Quote Link to comment https://forums.phpfreaks.com/topic/120854-solved-dates-not-being-added/#findComment-622978 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.