Well, I am attempting to update a error I receive with a date in a mysql table.
The table is and I am told to switch to datetime. The error I keep getting is the table does not index the logs and the select grabs a date from one log and a time from another.
--
-- Table structure for table `log_login`
--

CREATE TABLE `log_login` (
`username` varchar(20) default NULL,
`date` varchar(30) default NULL,
`time` varchar(30) default NULL,
`ip_addr` varchar(20) default NULL,
`oper_sys` varchar(20) default NULL,
`brow` varchar(20) default NULL,
KEY `date` (`date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
and the function.php to insert into is - in part

//sets date and time variables
$last = gmdate("m-d-Y", time() + $zone);
$time = gmdate("g:i:a", time() + $zone);

//make the connection to the database
$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());

//build and issue the query
$sql ="INSERT INTO log_login VALUES
('$_SESSION[user_name]', '$last', '$time', '$ip', '$platform', '$browser')";
$result = @mysql_query($sql,$connection) or die(mysql_error());
and the select

<?$connection = @mysql_connect($server, $dbusername, $dbpassword)
or die(mysql_error());

$db = @mysql_select_db($db_name,$connection)
or die(mysql_error());

$sql="SELECT * FROM log_login WHERE username = '$_SESSION[user_name]' GROUP BY time ORDER BY date DESC LIMIT 1,1";
$result = @mysql_query($sql, $connection) or die(mysql_error());

while ($sql = mysql_fetch_object($result))
{
$whent = $sql -> date;

echo "<font size=\"2\" face=\"Tahoma\"><b>Date: </b>$whent</font><br>";
}
?>
</p>

<p align=center style='text-align:center'>
<?$connection = @mysql_connect($server, $dbusername, $dbpassword)
or die(mysql_error());

$db = @mysql_select_db($db_name,$connection)
or die(mysql_error());

$sql="SELECT * FROM log_login WHERE username = '$_SESSION[user_name]' GROUP BY time ORDER BY date DESC LIMIT 1,1";
$result = @mysql_query($sql, $connection) or die(mysql_error());

while ($sql = mysql_fetch_object($result))
{
$whent = $sql -> time;

echo "<font size=\"2\" face=\"Tahoma\"><b>Time: </b>$whent</font><br>";
}
?>
</p>
Every time I mess with this code I just make things, well, more complicated then need be. Right?