kee2ka4 Posted September 11, 2011 Share Posted September 11, 2011 Hey Guys, I am fixing someone else's code, so please bear with me on this one. Basically the site has an application form and once the user has submitted the form, they get an automated email with an induction date, and the date is taken from the admin panel where the admin user puts in the date and time and number of applicants. So basically the if the admin user puts in Date: 23th Sept 2011 Time: 9:30 Number of Applicants: 30, the next 30 successfull applicants will get that date and time. The problem with the code is that now whenever the user fills in the application and their application is successfull, they are getting an induction date of Thursday, 1 January 1970 and no time. I am not sure why this happens if someone could point me in the right direction. Here is the snipet of the code where it prints out the date: Your Induction date is <?php echo (date("l, j F Y", strtotime($array_result_ind['date'])))." at ".$array_result_ind['hour'];?> The code at the top of the page is: <?php //include('browser_redirect.php'); //Start session and page session_start(); $induction = isset($_GET['id'])?$_GET['id']:''; $_SESSION['change_ind_date_app_ID'] = $induction; $db_leafletj_jobs = mysql_connect("localhost", "leafletj_jobs", "t10872") or die(mysql_error()); $sel_leafletj_jobs = mysql_select_db("leafletj_jobs") or die(mysql_error()); $query_str = "SELECT applicants.id, applicants.unique_ref, applicants.app_date, applicants.fname, applicants.surname, applicants.ind_date, applicants.ind_ord_no, inductions.date, inductions.hour FROM (applicants JOIN inductions ON (applicants.ind_date = inductions.date)) WHERE applicants.id=".$induction; $result_ind = mysql_query($query_str, $db_leafletj_jobs) or die(mysql_error()); //$count = mysql_num_rows($result_ind); $array_result_ind = mysql_fetch_array($result_ind, MYSQL_BOTH); ?> Also the database for the induction date and time is blank. I haven't designed the application so I am a little lost. I the system was all working a couple of weeks ago but now all of a sudden it prints out that 1970 date with no time. Is this a quick fix? Thanks, Ken Quote Link to comment https://forums.phpfreaks.com/topic/246904-php-code-prints-out-1-january-1970-and-no-time/ Share on other sites More sharing options...
jasonc Posted September 11, 2011 Share Posted September 11, 2011 as you say the database is empty so the top part of the code in your page will get the date from the database and then the print date part of your page will print the default date based on 'NULL' or zero being the date in the database, default date will always be the same date time, the start of UNIX time. being zero which is 1 January 1970. also just for security, change the password on the databases and when submitting scripts maskout ( *** ) any passwords. the fix, ;-) add in a date in the field `date` in the admin panel Quote Link to comment https://forums.phpfreaks.com/topic/246904-php-code-prints-out-1-january-1970-and-no-time/#findComment-1267964 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.