PDA

View Full Version : Something Simple Keep Getting A Parse Error


tomyknoker
04-10-2007, 04:02 PM
I have the following:

while ($qry = mysql_fetch_array($results)) {
if (strtotime($qry['loginDateTime']) <= (time() + 86400*31)) {
$login .= 'Name: '.$qry["FirstName"].' '.$qry["LastName"].' ('.$qry["loginDateTime"].') '.$qry["Email"].'
';
}[php] And I am trying to add the below in place of the "loginDateTime" $qry... I keep getting a parse error I think it's me not putting the ))) in the right spot... If anyone could help would be much appreciated!

[php] ($qry["loginDateTime"]?date("d/m/Y H:i:s", strtotime($qry["loginDateTime"])):'unknown'.)

Nightfire
04-10-2007, 04:28 PM
Remove fullstop after 'unknown'

tomyknoker
04-10-2007, 04:30 PM
Sorry I didn't explain I was trying to replace the loginDateTime with the second part... I know I have a bracket error but can't work out the combo... Any ideas?


while ($qry = mysql_fetch_array($results)) {
if (strtotime($qry['loginDateTime']) <= (time() + 86400*31)) {
$login .= 'Name: '.$qry["FirstName"].' '.$qry["LastName"].' ('.$qry["loginDateTime"]?date("d/m/Y H:i:s", strtotime($qry["loginDateTime"])):'unknown') '.$qry["Email"].'
';
}

aedrin
04-10-2007, 05:15 PM
date("d/m/Y H:i:s", strtotime($qry["loginDateTime"]))

Are you storing a date/time as a string? (varchar, text, etc.)

I hope you are either storing it as an integer (unixtime) or datetime field.

tomyknoker
04-10-2007, 05:20 PM
Yes it's a DATETIME type in the MySQL database...

aedrin
04-10-2007, 05:22 PM
Then you should format the date in the query. Look up MySQL's date_format().