Hi everyone,
I have a table where I need to select the row containing the maximum timestamp.
time is of type timestamp
$sql2=" SELECT * FROM userdata WHERE time=MAX(time)";
$result=mysql_query($sql2) or die(mysql_error());
$output=mysql_fetch_array($result);
echo "<br /><br />";
echo $output['time'];
echo "<br /><br />";
I’m getting the output “Invalid use of group function”
If I try
$sql2="SELECT MAX(time) FROM userdata";
$result=mysql_query($sql2) or die(mysql_error());
$output=mysql_fetch_array($result);
echo "<br /><br />";
echo $output['time'];
echo "<br /><br />";
I get “Undefined index: time”
Does anyone know what I’m doing wrong?
Thank you very much.