Jump to content

php code prints out 1 january 1970 and no time


kee2ka4

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.